代码之家  ›  专栏  ›  技术社区  ›  kolek

实体框架,无法加载Microsoft的文件或程序集。扩展。依赖性注射。摘要,版本=3.1.0.0

  •  0
  • kolek  · 技术社区  · 2 年前

    我正在尝试构建一个API。net核心并托管在Azure应用程序服务中。该设置由几个项目组成,但有两个项目具有实体框架。1.数据访问项目我有EF上下文、迁移等,2.我的web应用上下文在DI中

    我的问题是:

    Application '/LM/W3SVC/..../ROOT' with physical root 'D:\home\site\wwwroot\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
    Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=.....'. The system cannot find the file specified.
    File name: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=.....'
       at Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(String[] args)
       at Name.Name.Program.CreateHostBuilder(String[] args)
    

    我在网上看了所有的东西,我都搞不懂。 我加入了微软。扩展。依赖性注射。抽象3.1.0删除了一些dll,添加了AutoGenerateBindingRedirects,GenerateBindingRedirectsOutputType在一个单独的PropertyGroup中,但都是徒劳的。 有趣的是,它在本地工作,但当我将其部署到azure时,它就不工作了。

    1数据访问csproj

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
      </PropertyGroup>
      
      <PropertyGroup>
      <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
      <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" />
        <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
      </ItemGroup>
    
      <ItemGroup>
        <ProjectReference Include="..\Name.Model\Name.Model.csproj" />
      </ItemGroup>
    
    </Project>
    
    

    2网络应用程序csproj

    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <GenerateDocumentationFile>True</GenerateDocumentationFile> 
      </PropertyGroup>
      
      <PropertyGroup>
      <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
      <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Azure.Storage.Files.Shares" Version="12.9.0" />
        <PackageReference Include="LazyCache.AspNetCore" Version="2.4.0" />
        <PackageReference Include="Microsoft.ApplicationInsights" Version="2.20.0" />
        <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
        <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.23" />
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" />
        <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
        <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.3.0" />
        <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
        <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.3.0" />
      </ItemGroup>
    
      <ItemGroup>
        <ProjectReference Include="..\Name.BusinessLogic\Name.BusinessLogic.csproj" />
        <ProjectReference Include="..\Name.DataAccessLayer\Name.DataAccessLayer.csproj" />
      </ItemGroup>
    
    
    </Project>
    
    0 回复  |  直到 2 年前