abp icon indicating copy to clipboard operation
abp copied to clipboard

Finding Missing Dependency on ArgumentNullException on InitializeServiceProvider

Open BoasE opened this issue 1 year ago • 6 comments

Is there an existing article or article request for this?

  • [x] I have searched the existing resources

Describe the article you'd like

After some refactorings of an existing system I get the following exception I assume that i missed a reference to regsiter, but the exception doesn't tell me which type the expcetion is related to.

How can I find the type which is missing a instance and which instance it is?

System.ArgumentNullException: Value cannot be null. (Parameter 'instance') at Autofac.Core.Activators.ProvidedInstance.ProvidedInstanceActivator.GetType(Object instance) at Autofac.Core.Activators.ProvidedInstance.ProvidedInstanceActivator..ctor(Object instance) at Autofac.RegistrationExtensions.RegisterInstance[T](ContainerBuilder builder, T instance) at Autofac.Extensions.DependencyInjection.AutofacRegistration.Register(ContainerBuilder builder, IEnumerable1 descriptors, Object lifetimeScopeTagForSingletons) at Autofac.Extensions.DependencyInjection.AutofacRegistration.Populate(ContainerBuilder builder, IEnumerable1 descriptors, Object lifetimeScopeTagForSingletons) at Autofac.Extensions.DependencyInjection.AutofacRegistration.Populate(ContainerBuilder builder, IEnumerable1 descriptors) at Autofac.Extensions.DependencyInjection.AutofacServiceProviderFactory.CreateBuilder(IServiceCollection services) at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter1.CreateBuilder(IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build()

BoasE avatar Jan 21 '25 10:01 BoasE

hi

After some refactorings of an existing system I get the following exception

What changes have you made?

maliming avatar Jan 22 '25 01:01 maliming

Had the same issue after updating the version of multiple other packages in my project. Updated Autofac to 8.2.0 too and it fixed the issue.

mirceamt avatar Mar 18 '25 02:03 mirceamt

I got same problem, but it required me to update whole abp to 8.2.0, not only abp.autofac package

quannguyen-smd-vault22 avatar Jun 05 '25 01:06 quannguyen-smd-vault22

hi @quannguyen-smd-vault22

How to reproduce?

maliming avatar Jun 05 '25 03:06 maliming

hi @quannguyen-smd-vault22

How to reproduce?

I'm don't have minimal project to re-procedure, but what I got is

  • my initial project (long time ago) doesn't include all Tenant module (for all layers)
  • I add all Tenant module back yesterday, when I start to run solution, it cause
System.ArgumentNullException: Value cannot be null. (Parameter 'instance')

Update Abp.Autofac to 8.2.0 will help the error more clear:

System.MissingMethodException: Method not found: 'System.Collections.Generic.List`1<System.Type> Volo.Abp.DependencyInjection.IOnServiceExposingContext.get_ExposedTypes()'.

so I decide to upgrade all other abp packages to 8.2.0, and the error disappear.

quannguyen-smd-vault22 avatar Jun 05 '25 03:06 quannguyen-smd-vault22

If you can share the minimal project, I can check it out.

maliming avatar Jun 05 '25 03:06 maliming