Open ryoasai opened 4 years ago
@ryoasai This is a good catch! I will add the fix into the next minor version.
I have the same issue on MAUI when simply calling: Resolve(). The stack trace:
at DryIoc.Interpreter.TryInterpretSingletonAndUnwrapContainerException(IResolverContext r, Expression expr, ImMapEntry`1 itemRef, Object& result)
at DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request)
at DryIoc.Factory.GetExpressionOrDefault(Request request)
at DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved)
at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved)
at DryIoc.Resolver.Resolve[TService](IResolver resolver, IfUnresolved ifUnresolved)
The service is registred like: container.Register<IStartupService, StartupService>(reuse: Reuse.Singleton);
The exception is thrown just inside ctor of StartupService.
DryIoc.dll version: 5.4.3
DryIoc.Microsoft.DependencyInjection version: 6.2.0
@dadhi can you take a look at this problem?
@raV720 Can you check the latest preview versions of the DryIoc.Microsoft.DependencyInjection and DryIoc.dll?
I had a trouble while debugging a thread safety problem of my code.
When executing all test cases, one of my test case failed with the following exception:
But when I execute the failed test case, it somehow passed.
At first I had a fooled impression that the problem is in DryIoc code, but after digging into the problem, I found the NullRefereneException was thrown in Dictionary class. It was my fault that I was using the plain Dictionary class as a cache. Replacing it with CuncurrentDictionary solved the problem.
That's ok but a annoyingly that the original exception stack trace is lost at the following code:
So it's not a DryIoC's bug per se but I think it's better that it will report the original stack trace to help debugging.
There seems to be a technique to keep the original stack trace, for example:
[https://stackoverflow.com/questions/57383/how-to-rethrow-innerexception-without-losing-stack-trace-in-c]()
Can you take a look at this problem? I'm currently using v4.1.3.