Finbuckle / Finbuckle.MultiTenant

Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
https://www.finbuckle.com/multitenant
Apache License 2.0
1.26k stars 256 forks source link

ReflectionTypeLoadException after updating from 6.x to 7.0.1 #838

Closed fbjerggaard closed 3 weeks ago

fbjerggaard commented 4 weeks ago

After updating from 6.x to 7.0.1 I am getting the following exception:

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.IMultiTenantStore`1' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken()
   at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
   at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.GetOrCreateDataSource(IEndpointRouteBuilder endpoints)
   at Microsoft.AspNetCore.Builder.ControllerEndpointRouteBuilderExtensions.MapControllers(IEndpointRouteBuilder endpoints)
   at Program.<Main>$(String[] args) in _\src\Api\Program.cs:line 248
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.IMultiTenantStore`1' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.
System.TypeLoadException: Could not load type 'Finbuckle.MultiTenant.ITenantInfo' from assembly 'Finbuckle.MultiTenant, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'.

It specifically breaks on app.MapControllers() in Program.cs

I am not injecting ITenantInfo anywhere but I am using IMultiTenantStore<TTenantInfo>

Have you seen this error before and have any pointers as to how to debug and fix it?

AndrewTriesToCode commented 4 weeks ago

Ho do you have a small example project that demonstrates the issue? It looks like a full restore of nugets or a solution clean build action might help.

fbjerggaard commented 3 weeks ago

Clean build didn't do it, but a restart of my machine did. Weird - never experienced that before.

Closing since it was an issue on my machine.

AndrewTriesToCode commented 3 weeks ago

Glad to hear it cleared up. I’ve seen similar issues and I think there must be some caching somewhere in the tool chain. I wish a clean solution build was more effective.