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.3k stars 265 forks source link

DataIsolationSample: Exception #258

Closed ZedZipDev closed 4 years ago

ZedZipDev commented 4 years ago

I have downloaded the Finbuckle.MultiTenant-release-6.0.0-dev Open the solution in VS2019, Finbuckle.MultiTenant-release-6.0.0-dev Run the project ASP.NET Core 3 DataIsolationSample:

System.AggregateException HResult=0x80131500 Message=Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: DataIsolationSample.Data.ToDoDbContext Lifetime: Scoped ImplementationType: DataIsolationSample.Data.ToDoDbContext': No constructor for type 'DataIsolationSample.Data.ToDoDbContext' can be instantiated using services from the service container and default values.) Source=Microsoft.Extensions.DependencyInjection StackTrace: at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable1 serviceDescriptors, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder) at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter1.CreateServiceProvider(Object containerBuilder) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at DataIsolationSample.Program.Main(String[] args) in G:\MyProjects_CrossPlatform\Multitenancy\Finbuckle.MultiTenant-release-6.0.0-dev\samples\ASP.NET Core 3\DataIsolationSample\Program.cs:line 15

This exception was originally thrown at this call stack: Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache, System.Type, System.Type, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Microsoft.Extensions.DependencyInjection.ServiceDescriptor, System.Type, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain, int) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Microsoft.Extensions.DependencyInjection.ServiceDescriptor, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain) Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(Microsoft.Extensions.DependencyInjection.ServiceDescriptor)

Inner Exception 1: InvalidOperationException: Error while validating the service descriptor 'ServiceType: DataIsolationSample.Data.ToDoDbContext Lifetime: Scoped ImplementationType: DataIsolationSample.Data.ToDoDbContext': No constructor for type 'DataIsolationSample.Data.ToDoDbContext' can be instantiated using services from the service container and default values. Inner Exception 2: InvalidOperationException: No constructor for type 'DataIsolationSample.Data.ToDoDbContext' can be instantiated using services from the service container and default values.

ZedZipDev commented 4 years ago

I have removed the NuGet and added the project and it works Something wrong wth NuGet

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.1" />
    <!--<PackageReference Include="Finbuckle.MultiTenant" Version="6.0.0-preview1" />-->
  </ItemGroup>

  <ItemGroup>
     <ProjectReference Include="..\..\..\src\Finbuckle.MultiTenant\Finbuckle.MultiTenant.csproj" /> 
  </ItemGroup>
</Project>
AndrewTriesToCode commented 4 years ago

@Oleg26Dev Thanks for creating the issue. I suspect it has to do with ITenantInfo not being injected correctly... I'm currently setting up a new computer so I haven't been able to test as usual. I will take a look at it this evening.

-Drew

ZedZipDev commented 4 years ago

Andrew, check my comment above

AndrewTriesToCode commented 4 years ago

Ah yes, I see it was still referencing the bad nuget package and not the code. Good catch.

AndrewTriesToCode commented 4 years ago

The branch is a few commits newer than the preview1 nuget package. I will get a preview2 nuget out this weekend.

AndrewTriesToCode commented 4 years ago

@Oleg26Dev Hello again! Preview2 should fix this.

ZedZipDev commented 4 years ago

Yes, the Preview2 is better. Thanx.