PrismLibrary / Prism

Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] crash when resolve an object after async function in maui app

ceasor opened this issue · comments

Description

It looks DryIoc.Container will crash when try to resolve object after async function.
s1

Steps to Reproduce

  1. debug the sample code MauiApp1. I attched the code:
    MauiApp1.zip

  2. Click button 'click me'
    s2

  3. will crash in code

Platform with bug

.NET MAUI

Affected platforms

Windows

Did you find any workaround?

try to avoid resolve object after an async function.

Relevant log output

No response

This is an error in your own code. There's just a lot of mess here... and I'm not sure what you're trying to accomplish but I am betting that if you're passing around the DI container you need to re-evaluate your architecture. While this is indeed sometimes necessary it is much more the exception that you should be using the DI container directly. Remember that you can do things like inject Lazy<T> or Func<T> by default with Prism.

Bottom line though if you new up another instance of your Tool and then don't set the IContainerProvider you shouldn't be surprised when you get a NullReferenceException.

Thanks for comments. I think I didn't reproduce the original problem. Sorry for wasting your time.

Thanks for comments. I think I didn't reproduce the original problem. Sorry for wasting your time.