dotnet core:找不到汇编文件Microsoft.CSharp.dll

Pou*_*sen 11 c# .net-core

我有一个项目,我有一段时间没有运行,使用dotnet核心1.1.2依赖项构建.

同时我更新了visual studio,可能为2.0安装了一些dotnet核心内容,我的应用程序不再运行了.

InvalidOperationException: Can not find assembly file Microsoft.CSharp.dll at 'C:\dev\EarthML\EarthML.Mapify\src\EarthML.Mapify.Portal\bin\Debug\net462\win10-x64\refs,C:\dev\EarthML\EarthML.Mapify\src\EarthML.Mapify.Portal\bin\Debug\net462\win10-x64\'
Microsoft.Extensions.DependencyModel.Resolution.AppBaseCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List<string> assemblies)
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能开始弄明白为什么它不起作用?

aet*_*boy 12

这似乎是当前版本的Visual Studio(15.3)的一个错误.底层问题是当Views正在尝试构建时,它们没有引用GAC,因此没有它们的依赖项.

虽然只是解决方法,但遇到此问题时最好的选择是复制丢失的DLL.我通过复制操作将它们设置为项目中的组件.一旦它被修复(目前为Triaged:https://developercommunity.visualstudio.com/content/problem/96927/runtime-error-after-upgrading-to-vs-153-invalidope.html),那么删除它们就成了问题.

编辑

或者,根据https://github.com/dotnet/sdk/issues/1488,将此作为对项目的引用添加应该可以工作,而不是添加所有依赖项:

<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.0" />
Run Code Online (Sandbox Code Playgroud)

  • 包"Microsoft.Extensions.DependencyModel"为我解决了这个问题. (4认同)

Pou*_*sen 1

我将应用程序升级到 dotnet core 2.0 和 razor 页面并解决了这个问题。