无法加载文件或程序集'System.Runtime,版本= 4.2.1.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a'
我从同事那里得到了项目,并且在构建项目时遇到了这个错误:
I got the project from colleague and got this error when building project:
无法加载文件或程序集'System.Runtime,版本= 4.2.1.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一.该系统找不到指定的文件.
Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
我猜该dll位于.NET Framework Dll文件夹中: C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework \ .NETFramework
,但是在搜索后,我发现许多dll其他版本,但我找不到任何 System.Runtime.dll
是 4.2.1.0
.
I guess this dll is in .NET Framework Dll Folder: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
, but after searching, I find many dll of other version, but I didn't find any System.Runtime.dll
is 4.2.1.0
.
这是另一个类似问题,但没有答案.
Here's another similar question but no answer to it.
.NET Framework中确实存在 System.Runtime.dll 4.2.1.0
吗?
Is System.Runtime.dll 4.2.1.0
really exists in .NET Framework?
我知道这是一篇过时的文章,但我认为与遇到此确切问题的其他人分享我的解决方案很有用.
I know this is an old post, but I think it's useful to share my solution with others that encounter this exact problem.
- 我通过终端创建了一个新的控制台应用程序:
dotnet新控制台
- 我在Visual Studio 2019中打开了控制台应用程序的文件夹.
- 我尝试使用
ctrl + f5
运行代码
- I created a new Console App via the terminal:
dotnet new console
- I opened the folder of the Console App in Visual Studio 2019.
- I tried to run the code using
ctrl + f5
那是我遇到的时间:无法加载文件或程序集'System.Runtime,Version = 5.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'
要解决此问题,我不得不在其中打开以 .csproj
结尾的文件,而不是在Visual Studio 2019中打开Console App文件夹,然后执行 ctrl + f5
.之后,它运行平稳.希望这对其他人有帮助.经过长时间的故障排除以找到解决方案.
To solve it, instead of opening the Console App folder in Visual Studio 2019, I had to open the file inside of it that ended with .csproj
and then doing ctrl + f5
. After that it ran smoothly. Hope this will help someone else. Been troubleshooting for a long time to find the solution.
TL; DR :在Visual Studio 2019中打开 .csproj
文件,而不是其所在的项目文件夹.
TL;DR: open the .csproj
file in Visual Studio 2019 instead of the project folder that it resides in.