Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error inside Container #116

Closed
tiagorosendo opened this issue Sep 5, 2017 · 9 comments
Closed

Error inside Container #116

tiagorosendo opened this issue Sep 5, 2017 · 9 comments
Milestone

Comments

@tiagorosendo
Copy link

When i try to run inside a container with aspnet:2.0 base image, i get this error:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.Win32.Registry' threw an exception. ---> System.PlatformNotSupportedException: Registry is not supported on this platform.
at Microsoft.Win32.RegistryKey.OpenBaseKeyCore(RegistryHive hKey, RegistryView view)
at Microsoft.Win32.Registry..cctor()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver.<>c.<.ctor>b__2_0()
at Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver.ResolvePolicy()
at Microsoft.AspNetCore.DataProtection.Internal.KeyManagementOptionsSetup.Configure(KeyManagementOptions options)
at Microsoft.Extensions.Options.OptionsFactory1.Create(String name) at Microsoft.Extensions.Options.OptionsManager1.<>c__DisplayClass5_0.b__0()
at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy1.CreateValue() at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd(String name, Func1 createOptions) at Microsoft.Extensions.Options.OptionsManager1.Get(String name)
at Microsoft.Extensions.Options.OptionsManager1.get_Value() at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager..ctor(IOptions1 keyManagementOptions, IActivator activator, ILoggerFactory loggerFactory)
at lambda_method(Closure , IExportLocatorScope , IDisposalScope , IInjectionContext )
at Grace.DependencyInjection.Lifestyle.SingletonLifestyle.ProvideLifestyleExpression(IInjectionScope scope, IActivationExpressionRequest request, Func2 activationExpression) at Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder.GetExpressionFromStrategyCollection(IInjectionScope scope, IActivationExpressionRequest request) at Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder.GetActivationExpressionFromStrategies(IInjectionScope scope, IActivationExpressionRequest request) at Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder.GetActivationExpression(IInjectionScope scope, IActivationExpressionRequest request) at Grace.DependencyInjection.Impl.Expressions.ConstructorExpressionCreator.GetParameterExpression(ParameterInfo parameter, ConstructorParameterInfo parameterInfo, IInjectionScope injectionScope, TypeActivationConfiguration configuration, IActivationExpressionRequest request) at Grace.DependencyInjection.Impl.Expressions.ConstructorExpressionCreator.GetParameterExpressionsForConstructor(IInjectionScope injectionScope, TypeActivationConfiguration configuration, IActivationExpressionRequest request, ConstructorInfo constructor) at Grace.DependencyInjection.Impl.Expressions.ConstructorExpressionCreator.CreateExpression(IInjectionScope scope, IActivationExpressionRequest request, TypeActivationConfiguration activationConfiguration) at Grace.DependencyInjection.Impl.Expressions.TypeExpressionBuilder.GetActivationExpression(IInjectionScope scope, IActivationExpressionRequest request, TypeActivationConfiguration activationConfiguration) at Grace.DependencyInjection.Lifestyle.SingletonLifestyle.ProvideLifestyleExpression(IInjectionScope scope, IActivationExpressionRequest request, Func2 activationExpression)
at Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder.GetExpressionFromStrategyCollection(IInjectionScope scope, IActivationExpressionRequest request)
at Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder.GetActivationExpressionFromStrategies(IInjectionScope scope, IActivationExpressionRequest request)
at Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder.GetActivationExpression(IInjectionScope scope, IActivationExpressionRequest request)
at Grace.DependencyInjection.Impl.Expressions.ConstructorExpressionCreator.GetParameterExpression(ParameterInfo parameter, ConstructorParameterInfo parameterInfo, IInjectionScope injectionScope, TypeActivationConfiguration configuration, IActivationExpressionRequest request)
at Grace.DependencyInjection.Impl.Expressions.ConstructorExpressionCreator.GetParameterExpressionsForConstructor(IInjectionScope injectionScope, TypeActivationConfiguration configuration, IActivationExpressionRequest request, ConstructorInfo constructor)
at Grace.DependencyInjection.Impl.Expressions.ConstructorExpressionCreator.CreateExpression(IInjectionScope scope, IActivationExpressionRequest request, TypeActivationConfiguration activationConfiguration)
at Grace.DependencyInjection.Impl.Expressions.TypeExpressionBuilder.GetActivationExpression(IInjectionScope scope, IActivationExpressionRequest request, TypeActivationConfiguration activationConfiguration)
at Grace.DependencyInjection.Lifestyle.SingletonLifestyle.ProvideLifestyleExpression(IInjectionScope scope, IActivationExpressionRequest request, Func`2 activationExpression)
at Grace.DependencyInjection.Impl.Expressions.ArrayExpressionCreator.GetActivationExpressionResultsFromStrategies(IInjectionScope scope, IActivationExpressionRequest request, Type arrayElementType)
at Grace.DependencyInjection.Impl.Expressions.ArrayExpressionCreator.GetArrayExpressionList(IInjectionScope scope, IActivationExpressionRequest request, Type arrayElementType)
at Grace.DependencyInjection.Impl.Expressions.ArrayExpressionCreator.GetArrayExpression(IInjectionScope scope, IActivationExpressionRequest request)
at Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder.GetActivationExpression(IInjectionScope scope, IActivationExpressionRequest request)
at Grace.DependencyInjection.Impl.ActivationStrategyCompiler.LocateEnumerableStrategy(IInjectionScope scope, Type locateType, ActivationStrategyFilter consider, Object key)
at Grace.DependencyInjection.Impl.ActivationStrategyCompiler.FindDelegate(IInjectionScope scope, Type locateType, ActivationStrategyFilter consider, Object key, IInjectionContext injectionContext, Boolean checkMissing)
at Grace.DependencyInjection.Impl.InjectionScope.InternalLocate(IExportLocatorScope scope, IDisposalScope disposalScope, Type type, ActivationStrategyFilter consider, Object key, IInjectionContext injectionContext, Boolean allowNull, Boolean isDynamic)
at Grace.DependencyInjection.Impl.InjectionScope.LocateOrDefault(Type type, Object defaultValue)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()

@ipjohnson
Copy link
Owner

Can you attach your Program.cs and Startup.cs? It looks like something going sideways in the DataProtection code but I'm not sure why.

@ipjohnson
Copy link
Owner

Also what platform are you on .net core 2.0, net 4.6.2? Windows, linux?

@ipjohnson
Copy link
Owner

Ok I was able to track the problem down to a change MS made to their own code and opened an issue. I'll look at adding some type of black listing feature for concrete types that works off names (the type is internal so it has to be name not typeof()).

Sorry you have to be the guinea pig, I didn't realize they were making so many DI refactoring changes that would ripple like this.

@ipjohnson
Copy link
Owner

This won't be addressed till MS releases asp.net core 2.1 so to bridge that gap I'll add a feature to Grace to allow you to black list types from being auto-registered (Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver specifically).

I'll see about doing a release in the next couple days to add this feature.

@davidfowl
Copy link

Sorry about this 😞

@ipjohnson
Copy link
Owner

@davidfowl these things happen especially when you have so many moving part that can be swapped in and out.

@tiagorosendo
Copy link
Author

@ipjohnson thanks for the fast support, i will wait for the Grace release =D

@ipjohnson ipjohnson added this to the 6.3.0 milestone Sep 6, 2017
@ipjohnson
Copy link
Owner

@tiagorosendo I've pushed a beta package if you could give it a whirl that would be great.

You'll need to add a call to ExcludeTypeFromAutoRegistration in your configuration code.

container.Configure(c =>
       c.ExcludeTypeFromAutoRegistration("Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver"));

@ipjohnson
Copy link
Owner

@tiagorosendo I'm going to close this out and push an official release tomorrow. Let me know if you run into any other asp.net 2.0 compatibility issues. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants