Skip to content

Error inside Container #116

Closed
Closed

Description

@tiagorosendo

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()

Activity

  1. ipjohnson commented on Sep 5, 2017

    @ipjohnson
    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.

  2. ipjohnson commented on Sep 5, 2017

    @ipjohnson
    Owner

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

  3. ipjohnson commented on Sep 5, 2017

    @ipjohnson
    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.

  4. ipjohnson commented on Sep 5, 2017

    @ipjohnson
    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.

  5. davidfowl commented on Sep 5, 2017

    @davidfowl

    Sorry about this 😞

  6. ipjohnson commented on Sep 5, 2017

    @ipjohnson
    Owner

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

  7. tiagorosendo commented on Sep 6, 2017

    @tiagorosendo
    Author

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

  8. added this to the 6.3.0 milestone on Sep 6, 2017
  9. ipjohnson commented on Sep 6, 2017

    @ipjohnson
    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"));
  10. ipjohnson commented on Sep 9, 2017

    @ipjohnson
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions