c# - dotnet 核心 : Can not find assembly file Microsoft. CSharp.dll

标签 c# .net-core

我有一个项目,我已经有一段时间没有运行了,它使用 dotnet core 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)

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

最佳答案

这似乎是当前版本的 Visual Studio (15.3) 的错误。潜在的问题是当 View 试图构建时,它们没有引用 GAC,因此没有它们的依赖性。

虽然只是一种变通方法,但遇到此问题时最好的办法是复制丢失的 DLL。我通过复制操作将它们设置为项目中的组件。一旦它得到修复(当前分类: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" />

关于c# - dotnet 核心 : Can not find assembly file Microsoft. CSharp.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45380712/

相关文章:

c# - XAML 基于绑定(bind)改变框架背景

c# - 创建 Game 类实例时出现 NullReferenceException (OpenTKGameWindow.Initialize)

visual-studio - 通过 Docker 使用自定义 Visual Studio 运行配置

c# - nuget 包 dll 或源文件

angular - Angular 和 .NET Core 的 SignalR CORS 问题

c# - PDF 格式的希伯来语文本

c# - 如何将 'System.IntPtr' 转换为 'float[]' ?

c# - 在 C# 中,在附加到文本文件的行上方和下方写入 n 行

c# - 如何从通过 API 返回的 Task<IActionResult> 获取值进行单元测试

c# - Path.TryJoin 相对于 .NET Core 中的 Path.Combine 有什么优势?