You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use RegisterDelegate<DbContext>(c => c.Resolve<ConcreteDbContext>()) which failed with a reflection exception. I have finally been able to reproduce it, even though I am not affected by it anymore thanks to #314
The rule WithTrackingDisposableTransients seems to be enabled by default, when using new DryIocServiceProviderFactory(new Container())) adapter for MsDI.
Foo represents the DbContext while Bar represents a concrete implementation of it.
With this combination, during resolving, the convert expression is no longer recognized as DelegateExpression in Interpreter.TryInterpret -> switch(expr.NodeType):ExprType.Convert. Because of that, the expression is interpreted as a usual Invoke Expression in the resulting TryInterpret call.
For some reason, the RuntimeMethodInfo created from Delegate.GetMethodInfo() declares the one parameter, that is actually used within the delegate. However, the Delegate.Method property, declares two parameters: First the delegate function, second the resolver context. As far as I can tell, this is the ToFactoryDelegate extension method declared in Registrator. Unfortunately, this is also the method actually being invoked - resulting in a TargetParameterCountException
Using .NET Core for Linux on Microsoft.NETCore.App 3.1.7 using dotnet-sdk 3.1.107
The text was updated successfully, but these errors were encountered:
This is a follow-up to #314
I was trying to use
RegisterDelegate<DbContext>(c => c.Resolve<ConcreteDbContext>())
which failed with a reflection exception. I have finally been able to reproduce it, even though I am not affected by it anymore thanks to #314Here is a minimal broken example:
The rule
WithTrackingDisposableTransients
seems to be enabled by default, when usingnew DryIocServiceProviderFactory(new Container()))
adapter for MsDI.Foo
represents theDbContext
whileBar
represents a concrete implementation of it.With this combination, during resolving, the convert expression is no longer recognized as DelegateExpression in
Interpreter.TryInterpret -> switch(expr.NodeType):ExprType.Convert
. Because of that, the expression is interpreted as a usual Invoke Expression in the resultingTryInterpret
call.For some reason, the
RuntimeMethodInfo
created fromDelegate.GetMethodInfo()
declares the one parameter, that is actually used within the delegate. However, theDelegate.Method
property, declares two parameters: First the delegate function, second the resolver context. As far as I can tell, this is theToFactoryDelegate
extension method declared inRegistrator
. Unfortunately, this is also the method actually being invoked - resulting in aTargetParameterCountException
Using .NET Core for Linux on Microsoft.NETCore.App 3.1.7 using dotnet-sdk 3.1.107
The text was updated successfully, but these errors were encountered: