dadhi / DryIoc

DryIoc is fast, small, full-featured IoC Container for .NET
MIT License
1.03k stars 122 forks source link

[Xamarin.iOS] DryIocTypeResolver.Resolve (System.Type type) SIGABRT: Operation is not supported on this platform. #532

Open JustickDM opened 2 years ago

JustickDM commented 2 years ago

DryIoc.dll vesions: 5.2.2, 5.2.1, 5.2.0, 5.1.0, 5.0.2, 5.0.1, 4.8.8 iOS version: 15.7 Xamarin.iOS: 16.0.0.72, 16.0.0.75, 15.10.0.5

The container is created like this:

var container = CurrentPlatform == Device.iOS
                ? new Container(Rules.Default.WithUseInterpretation())
                : new Container();

Maybe this line - https://github.com/dadhi/DryIoc/blob/master/src/DryIoc/FastExpressionCompiler.cs#L459

This only happens in the release configuration (TestFlight) when navigating to the page again (Xamarin.Forms project)

StackTrace: Xamarin Exception Stack: System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Reflection.Emit.DynamicMethod..ctor (System.String name, System.Type returnType, System.Type[] parameterTypes, System.Type owner, System.Boolean skipVisibility) <0x103346df0 + 0x00010> in <ae4d2b2e1a52451bbb0fbe726a40b592#80ffc4493c7251d006b14594f2d9afb9>:0 at DryIoc.FastExpressionCompiler.LightExpression.ExpressionCompiler.CompileNoArgsNew (System.Reflection.ConstructorInfo ctor, System.Type delegateType, System.Type[] closurePlusParamTypes, System.Type returnType) <0x1048b18e4 + 0x0006f> in <78cda8c2f8b0438899aa3a8eeea13482#80ffc4493c7251d006b14594f2d9afb9>:0 at DryIoc.FastExpressionCompiler.LightExpression.ExpressionCompiler.TryCompileBoundToFirstClosureParam (System.Type delegateType, DryIoc.FastExpressionCompiler.LightExpression.Expression bodyExpr, DryIoc.FastExpressionCompiler.LightExpression.IParameterProvider paramExprs, System.Type[] closurePlusParamTypes, System.Type returnType, DryIoc.FastExpressionCompiler.LightExpression.CompilerFlags flags) <0x1048b19f8 + 0x00173> in <78cda8c2f8b0438899aa3a8eeea13482#80ffc4493c7251d006b14594f2d9afb9>:0 at DryIoc.FactoryDelegateCompiler.CompileToFactoryDelegate (DryIoc.FastExpressionCompiler.LightExpression.Expression expression, System.Boolean preferInterpretation) <0x10480bff8 + 0x0011b> in <78cda8c2f8b0438899aa3a8eeea13482#80ffc4493c7251d006b14594f2d9afb9>:0 at DryIoc.Container.DryIoc.IResolver.Resolve (System.Type serviceType, DryIoc.IfUnresolved ifUnresolved) <0x1047ee1bc + 0x0031b> in <78cda8c2f8b0438899aa3a8eeea13482#80ffc4493c7251d006b14594f2d9afb9>:0 at DryIoc.Resolver.Resolve (DryIoc.IResolver resolver, System.Type serviceType) <0x10482a170 + 0x00047> in <78cda8c2f8b0438899aa3a8eeea13482#80ffc4493c7251d006b14594f2d9afb9>:0

dadhi commented 2 years ago

@JustickDM Hi, thanks for reporting. I need to process what's happening here.

JustickDM commented 2 years ago

@JustickDM Hi, thanks for reporting. I need to process what's happening here.

Hi, 4.8.8 - same, even with the use of WithUseInterpretation + WithoutFastExpressionCompiler

JustickDM commented 2 years ago

I migrated to Microsoft Extensions DependencyInjection and everything is fine, so you have a bug somewhere

dadhi commented 2 years ago

@JustickDM Ok. Regarding the issue I am trying and not able to reproduce, is it possible that CurrentPlatform == Device.iOS was false?

JustickDM commented 2 years ago

@JustickDM Ok. Regarding the issue I am trying and not able to reproduce, is it possible that CurrentPlatform == Device.iOS was false?

No, of course it's true. I've been using the library in production on the AppStore and Google Play for almost a year now.

dadhi commented 1 year ago

Linking the #552