Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

System.ArgumentException during startup #5612


User avatar
0
statuscast created

Does anyone else experience a large number of exceptions during startup in AppNameCoreModule.cs:

line 109: IocManager.Resolve<ChatUserStateWatcher>().Initialize();

Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll
System.ArgumentException: 'Null is not a valid constant value for this type.'

I'm trying to debug the MVC app startup time and just happened to notice this.. probably not related but figured it would be worth reporting.


14 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Can you share the error stack trace as well?

  • User Avatar
    0
    statuscast created

    Here's the stack trace. Unfortunately I had to use the Call Stack window, as the stack trace listed in the exception is showing only

    System.ArgumentException HResult=0x80070057 Message=Null is not a valid constant value for this type. Source=System.Private.CoreLib StackTrace: at System.Reflection.Emit.TypeBuilder.SetConstantValue(ModuleBuilder module, Int32 tk, Type destType, Object value)

    Here's the full Call Stack Window:

    System.Private.CoreLib.dll!System.Reflection.Emit.TypeBuilder.SetConstantValue(System.Reflection.Emit.ModuleBuilder module, int tk, System.Type destType, object value)
    Castle.Core.dll!Castle.DynamicProxy.Generators.Emitters.MethodEmitter.CopyDefaultValueConstant(System.Reflection.ParameterInfo from, System.Reflection.Emit.ParameterBuilder to)
    Castle.Core.dll!Castle.DynamicProxy.Generators.Emitters.MethodEmitter.DefineParameters(System.Reflection.ParameterInfo[] parameters)
    Castle.Core.dll!Castle.DynamicProxy.Contributors.ClassProxyTargetContributor.CreateCallbackMethod(Castle.DynamicProxy.Generators.Emitters.ClassEmitter emitter, System.Reflection.MethodInfo methodInfo, System.Reflection.MethodInfo methodOnTarget)
    Castle.Core.dll!Castle.DynamicProxy.Contributors.ClassProxyTargetContributor.BuildInvocationType(Castle.DynamicProxy.Generators.MetaMethod method, Castle.DynamicProxy.Generators.Emitters.ClassEmitter class, Castle.DynamicProxy.ProxyGenerationOptions options)
    Castle.Core.dll!Castle.DynamicProxy.Contributors.ClassProxyTargetContributor.GetMethodGenerator(Castle.DynamicProxy.Generators.MetaMethod method, Castle.DynamicProxy.Generators.Emitters.ClassEmitter class, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.Contributors.OverrideMethodDelegate overrideMethod)
    Castle.Core.dll!Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementMethod(Castle.DynamicProxy.Generators.MetaMethod method, Castle.DynamicProxy.Generators.Emitters.ClassEmitter class, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.Contributors.OverrideMethodDelegate overrideMethod)
    Castle.Core.dll!Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(Castle.DynamicProxy.Generators.Emitters.ClassEmitter class, Castle.DynamicProxy.ProxyGenerationOptions options)
    Castle.Core.dll!Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType(string name, System.Type[] interfaces, Castle.DynamicProxy.Generators.INamingScope namingScope)
    Castle.Core.dll!Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(Castle.DynamicProxy.Generators.CacheKey cacheKey, System.Func<string, Castle.DynamicProxy.Generators.INamingScope, System.Type> factory)
    Castle.Core.dll!Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, Castle.DynamicProxy.IInterceptor[] interceptors)
    Castle.Windsor.dll!Castle.Windsor.Proxy.DefaultProxyFactory.Create(Castle.MicroKernel.IKernel kernel, object target, Castle.Core.ComponentModel model, Castle.MicroKernel.Context.CreationContext context, object[] constructorArguments)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(Castle.MicroKernel.Context.CreationContext context, Castle.Core.ConstructorCandidate constructor, object[] arguments)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(Castle.MicroKernel.Context.CreationContext context, bool trackedExternally)
    Castle.Windsor.MsDependencyInjection.dll!Castle.Windsor.MsDependencyInjection.MsScopedLifestyleManager.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.IReleasePolicy releasePolicy) Line 26
    	at D:\Github\castle-windsor-ms-adapter\src\Castle.Windsor.MsDependencyInjection\MsScopedLifestyleManager.cs(26)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(Castle.MicroKernel.Context.CreationContext context, bool requiresDecommission, bool instanceRequired, out Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.Resolve(Castle.MicroKernel.Context.CreationContext context, bool instanceRequired)
    Castle.Windsor.dll!Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.ISubDependencyResolver contextHandlerResolver, Castle.Core.ComponentModel model, Castle.Core.DependencyModel dependency)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(Castle.Core.ConstructorCandidate constructor, Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(Castle.MicroKernel.Context.CreationContext context, bool trackedExternally)
    Castle.Windsor.MsDependencyInjection.dll!Castle.Windsor.MsDependencyInjection.MsScopedLifestyleManager.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.IReleasePolicy releasePolicy) Line 26
    	at D:\Github\castle-windsor-ms-adapter\src\Castle.Windsor.MsDependencyInjection\MsScopedLifestyleManager.cs(26)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(Castle.MicroKernel.Context.CreationContext context, bool requiresDecommission, bool instanceRequired, out Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.Resolve(Castle.MicroKernel.Context.CreationContext context, bool instanceRequired)
    Castle.Windsor.dll!Castle.MicroKernel.DefaultKernel.ResolveComponent(Castle.MicroKernel.IHandler handler, System.Type service, System.Collections.IDictionary additionalArguments, Castle.MicroKernel.IReleasePolicy policy)
    Castle.Windsor.dll!Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(System.Type service, System.Collections.IDictionary arguments, Castle.MicroKernel.IReleasePolicy policy)
    Castle.Windsor.MsDependencyInjection.dll!Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetServiceInternal(System.Type serviceType, bool isOptional) Line 55
    	at D:\Github\castle-windsor-ms-adapter\src\Castle.Windsor.MsDependencyInjection\ScopedWindsorServiceProvider.cs(55)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.FactoryMethodActivator<object>.Instantiate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(Castle.MicroKernel.Context.CreationContext context, bool trackedExternally)
    Castle.Windsor.MsDependencyInjection.dll!Castle.Windsor.MsDependencyInjection.MsScopedLifestyleManager.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.IReleasePolicy releasePolicy) Line 26
    	at D:\Github\castle-windsor-ms-adapter\src\Castle.Windsor.MsDependencyInjection\MsScopedLifestyleManager.cs(26)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(Castle.MicroKernel.Context.CreationContext context, bool requiresDecommission, bool instanceRequired, out Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.Resolve(Castle.MicroKernel.Context.CreationContext context, bool instanceRequired)
    Castle.Windsor.dll!Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.ISubDependencyResolver contextHandlerResolver, Castle.Core.ComponentModel model, Castle.Core.DependencyModel dependency)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(Castle.Core.ConstructorCandidate constructor, Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(Castle.MicroKernel.Context.CreationContext context, bool trackedExternally)
    Castle.Windsor.dll!Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.IReleasePolicy releasePolicy)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(Castle.MicroKernel.Context.CreationContext context, bool requiresDecommission, bool instanceRequired, out Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.Resolve(Castle.MicroKernel.Context.CreationContext context, bool instanceRequired)
    Castle.Windsor.dll!Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.ISubDependencyResolver contextHandlerResolver, Castle.Core.ComponentModel model, Castle.Core.DependencyModel dependency)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(Castle.Core.ConstructorCandidate constructor, Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(Castle.MicroKernel.Context.CreationContext context)
    Castle.Windsor.dll!Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(Castle.MicroKernel.Context.CreationContext context, bool trackedExternally)
    Castle.Windsor.dll!Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.IReleasePolicy releasePolicy)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(Castle.MicroKernel.Context.CreationContext context, bool requiresDecommission, bool instanceRequired, out Castle.MicroKernel.Burden burden)
    Castle.Windsor.dll!Castle.MicroKernel.Handlers.DefaultHandler.Resolve(Castle.MicroKernel.Context.CreationContext context, bool instanceRequired)
    Castle.Windsor.dll!Castle.MicroKernel.DefaultKernel.ResolveComponent(Castle.MicroKernel.IHandler handler, System.Type service, System.Collections.IDictionary additionalArguments, Castle.MicroKernel.IReleasePolicy policy)
    Castle.Windsor.dll!Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(System.Type service, System.Collections.IDictionary arguments, Castle.MicroKernel.IReleasePolicy policy)
    Castle.Windsor.dll!Castle.Windsor.WindsorContainer.Resolve<StatusCast.Friendships.ChatUserStateWatcher>()
    StatusCast.Core.dll!StatusCast.StatusCastCoreModule.PostInitialize() Line 109
    	at C:\src\statuscast\server.v3\src\StatusCast.Core\StatusCastCoreModule.cs(109)
    System.Private.CoreLib.dll!System.Collections.Generic.List<Abp.Modules.AbpModuleInfo>.ForEach(System.Action<Abp.Modules.AbpModuleInfo> action)
    Abp.dll!Abp.AbpBootstrapper.Initialize() Line 155
    	at D:\Github\aspnetboilerplate\src\Abp\AbpBootstrapper.cs(155)
    Abp.AspNetCore.dll!Abp.AspNetCore.AbpApplicationBuilderExtensions.InitializeAbp(Microsoft.AspNetCore.Builder.IApplicationBuilder app) Line 67
    	at D:\Github\aspnetboilerplate\src\Abp.AspNetCore\AspNetCore\AbpApplicationBuilderExtensions.cs(67)
    Abp.AspNetCore.dll!Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action<Abp.AspNetCore.AbpApplicationBuilderOptions> optionsAction) Line 38
    	at D:\Github\aspnetboilerplate\src\Abp.AspNetCore\AspNetCore\AbpApplicationBuilderExtensions.cs(38)
    StatusCast.Web.Mvc.dll!StatusCast.Web.Startup.Startup.Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) Line 171
    	at C:\src\statuscast\server.v3\src\StatusCast.Web.Mvc\Startup\Startup.cs(171)
    [Native to Managed Transition]
    [Managed to Native Transition]
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(object instance, Microsoft.AspNetCore.Builder.IApplicationBuilder builder)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(System.Threading.CancellationToken cancellationToken)
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.AspNetCore.Hosting.Internal.WebHost.<StartAsync>d__26>(ref Microsoft.AspNetCore.Hosting.Internal.WebHost.<StartAsync>d__26 stateMachine)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(System.Threading.CancellationToken cancellationToken)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token, string shutdownMessage)
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__5>(ref Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__5 stateMachine)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token, string shutdownMessage)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token)
    System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__4>(ref Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__4 stateMachine)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token)
    Microsoft.AspNetCore.Hosting.dll!Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(Microsoft.AspNetCore.Hosting.IWebHost host)
    StatusCast.Web.Mvc.dll!StatusCast.Web.Startup.Program.Main(string[] args) Line 10
    	at C:\src\statuscast\server.v3\src\StatusCast.Web.Mvc\Startup\Program.cs(10)
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you divide the line into two parts for resolving the ChatUserStateWatcher and calling it's initialize method to see which one causes the problem.

    By the way, we haven't faced such a problem before.

  • User Avatar
    0
    statuscast created
    public override void PostInitialize()
            {
                IocManager.RegisterIfNot<IChatCommunicator, NullChatCommunicator>();
    
                var x = IocManager.Resolve<ChatUserStateWatcher>();
                x.Initialize();
                IocManager.Resolve<AppTimes>().StartupTime = Clock.Now;
            }
    

    It's happening on the .Resolve<ChatUserStateWatcher>()
    The app just rushes right past it, so it's not a "problem" per se. Just doesn't look right.

  • User Avatar
    -1
    alper created
    Support Team

    hi,

    delete all bin & obj folders and try again.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @statuscast have you tried @alper's suggestion ?

  • User Avatar
    0
    statuscast created

    will try today.

  • User Avatar
    0
    ismcagdas created
    Support Team

    For now, the support is moved to email. I will update here when we resolve the issue.

  • User Avatar
    0
    alper created
    Support Team

    closing due to inactivity.

  • User Avatar
    1
    krugerm created

    FWIW I'm seeing exactly the same issue, even after deleting all the bin & obj folders.

    Hundreds of System.ArgumentExceptions ("Null is not a valid constant value for this type.") are thrown when calling IocManager.Resolve<>() during initialisation.

    Ignoring System.ArgumentException in Exception Settings allows the app to load and function OK apparently.

  • User Avatar
    0
    bepi2002 created

    I have same problem. Any updates?

  • User Avatar
    0
    bepi2002 created

    Dependency cycle has been detected when trying to resolve component 'informare.Infocus.Friendships.ChatUserStateWatcher'. The resolution tree that resulted in the cycle is the following: Component 'informare.Infocus.Friendships.ChatUserStateWatcher' resolved as dependency of component 'informare.Infocus.Authorization.Users.UserStore_c8b38f56-7c07-46fb-8e64-c3d097b187e8' resolved as dependency of component 'Microsoft.AspNetCore.Identity.UserManager`1[[informare.Infocus.Authorization.Users.User, informare.Infocus.Core, Version=6.5.0.0, Culture=neutral, PublicKeyToken=null]]_ee3dcc72-de9f-4adf-9f9f-a1a030f8a886' resolved as dependency of component 'informare.Infocus.Authorization.Users.UserManager_b0cbbbba-4276-4361-bd5c-dcff0251e9b1' resolved as dependency of component 'informare.Infocus.Friendships.Cache.UserFriendsCache' resolved as dependency of component 'informare.Infocus.Friendships.ChatUserStateWatcher' which is the root component being resolved.

  • User Avatar
    0
    ipservant created

    I have the same or a similar Problem after upgrading my source code with the Version 6.7. Must have overtaken like 2 minor versions.

    I was able to track it down from

         public override void PostInitialize()
        {
            IocManager.RegisterIfNot&lt;IChatCommunicator,             NullChatCommunicator&gt;();
           IocManager.Resolve&lt;ChatUserStateWatcher&gt;().Initialize();
            
            ..
            //which needs 
            IocManager.Resolve&lt;IUserFriendsCache&gt;();
            //which needs
            IocManager.Resolve&lt;UserManager&gt;();
            //which needs
            var user = IocManager.Resolve&lt;UserStore&gt;();
            //which has apparently a circular reference (see above)
    

    what should we do. Looks harmful to me if no UserManager is there.

  • User Avatar
    0
    ashgadala created

    I started having this issue as well. I tried deleating obj and bin files. Is there any resolution