首页 > 解决方案 > NETCore Web 应用启动时无法加载文件或程序集

问题描述

NetCore 2.2在使用 VS2017 发布后使用以下设置部署应用程序时,使用 开发的应用程序出现问题: - 发布 - netcoreapp2.2 - Framework-Dependant - win-x64 到 IIS 服务器开始它说:

Application startup exception
System.IO.FileNotFoundException: Could not load file or assembly 'Jump.Shared.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Impossible to find specified file.
File name: 'Jump.Shared.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

现在问题似乎是我的引用结构。我有主要项目,Scan.Web它正在引用Scan.CoreScan.Infrastructure这里是 .csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    ...
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Scan.Core\Scan.Core.csproj" />
    <ProjectReference Include="..\Scan.Infrastructure\Scan.Infrastructure.csproj" />
  </ItemGroup>
</Project>

然后Scan.Infrastructure是引用有问题的Jump.Shared.Infrastructure,这里是csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    ...
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\JumpShared\Jump.Shared.Infrastructure\Jump.Shared.Infrastructure.csproj" />
    <ProjectReference Include="..\Scan.Core\Scan.Core.csproj" />
  </ItemGroup>
</Project>

最后是罪魁祸首的.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
    <PackageReference Include="MongoDB.Driver" Version="2.8.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Jump.Shared.Core\Jump.Shared.Core.csproj" />
  </ItemGroup>

</Project>

我不知道为什么,当在 VS2017 的调试中一切正常,在 IIS 上发布它时,它无法找到这个参考。构建给了我Jump.Shared.Infrastructure.dll

标签: c#.netasp.net-mvcasp.net-coreasp.net-core-2.2

解决方案


推荐阅读