C# 无法加载文件或程序集“系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”或其依赖项之一
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17648647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies
提问by Tema T.
I have this exception generated on some user machines (~1 of 20):
我在某些用户计算机上生成了此异常(大约 20 个中的 1 个):
Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
无法加载文件或程序集“系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”或其依赖项之一。该系统找不到指定的文件。
I found several references to this error over the web and this site but nothing helped.
我在网络和本网站上发现了一些对这个错误的引用,但没有任何帮助。
I have an add-in application which uses WCF to connect to the server. The add-in built with .NET Framework 3.5 with VS 2008.
我有一个使用 WCF 连接到服务器的加载项应用程序。使用 .NET Framework 3.5 和 VS 2008 构建的加载项。
The error is reproducible on one of the test machines in only one user account. I install my application and can only reproduce this from one account on this machine everywhere else it is working fine. Furthermore it is only reproducible with only one version of host application which I created add-in for (I assume because it uses differnet .NET Frameworks).
该错误仅在一个用户帐户中在其中一台测试机器上重现。我安装了我的应用程序,并且只能在这台机器上的一个帐户中复制此应用程序,其他任何地方都可以正常工作。此外,它只能在我为其创建加载项的一个主机应用程序版本中重现(我假设是因为它使用不同的 .NET 框架)。
I have checked the fuse logs and I see the following:
我检查了保险丝日志,我看到以下内容:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable C:\Program Files\SolidWorks Corp\SolidWorks\sldworks.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = Home\User
LOG: DisplayName = System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/SolidWorks Corp/SolidWorks/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
So by some reasons it is trying to use v2.0.50727\mscorwks.dll loader to load the Version=4.0.0.0 of System.dll. On build machine I'm referring 2.0.0.0 version of System.dll
因此,由于某些原因,它试图使用 v2.0.50727\mscorwks.dll 加载器来加载 System.dll 的 Version=4.0.0.0。在构建机器上,我指的是 System.dll 的 2.0.0.0 版本
Any help is much appreciated.
任何帮助深表感谢。
Thanks, Artem
谢谢,阿尔乔姆
回答by Cadburry
You are using .net 4? - Maybe on the clients there is only the ".net framework 4 client profile" installed. Try to install full package!! Download here
您正在使用 .net 4?- 也许在客户端上只安装了“.net framework 4 客户端配置文件”。尝试安装完整包!! 在这里下载
回答by Chris Moschini
I had this same problem - some users could pull from git and everything ran fine. Some would pull and get a very similar exception:
我遇到了同样的问题 - 一些用户可以从 git 中提取并且一切正常。有些人会拉并得到一个非常相似的异常:
Could not load file or assembly '..., Version=..., Culture=neutral, PublicKeyToken=...' or one of its dependencies. The system cannot find the file specified.
无法加载文件或程序集 '..., Version=..., Culture=neutral, PublicKeyToken=...' 或其依赖项之一。该系统找不到指定的文件。
In my particular case it was AjaxMin, so the actual error looked like this but the details don't matter:
在我的特殊情况下,它是 AjaxMin,所以实际错误看起来像这样,但细节无关紧要:
Could not load file or assembly 'AjaxMin, Version=4.95.4924.12383, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f' or one of its dependencies. The system cannot find the file specified.
无法加载文件或程序集“AjaxMin,版本=4.95.4924.12383,Culture=neutral,PublicKeyToken=21ef50ce11b5d80f”或其依赖项之一。该系统找不到指定的文件。
It turned out to be a result of the following actions on a Solution:
结果证明是对解决方案执行以下操作的结果:
NuGet Package Restore was turned on for the Solution.
A Project was added, and a Nuget package was installed into it (AjaxMin in this case).
The Project was moved to different folder in the Solution.
The Nuget package was updated to a newer version.
已为解决方案启用 NuGet 包还原。
添加了一个项目,并在其中安装了一个 Nuget 包(在本例中为 AjaxMin)。
项目已移至解决方案中的不同文件夹。
Nuget 包已更新到较新版本。
And slowly but surely this bug started showing up for some users.
慢慢但肯定地,这个错误开始出现在一些用户身上。
The reason was the Solution-level packages/respositories.config kept the old Project reference, and now had a new, second entry for the moved Project. In other words it had this before the reorg:
原因是解决方案级别的 packages/respositories.config 保留了旧的项目引用,现在为移动的项目提供了一个新的第二个条目。换句话说,它在重组之前有这个:
<repository path="..\Old\packages.config" />
And this after the reorg:
这在重组之后:
<repository path="..\Old\packages.config" />
<repository path="..\New\packages.config" />
So the first line now refers to a Project that, while on disk, is no longer part of my Solution.
所以第一行现在指的是一个项目,虽然在磁盘上,它不再是我的解决方案的一部分。
With Nuget Package Restore on, both packages.config files were being read, which each pointed to their own list of Nuget packages and package versions. Until a Nuget package was updated to a newer version however, there weren't any conflicts.
启用 Nuget 包还原后,将读取两个 packages.config 文件,每个文件都指向自己的 Nuget 包和包版本列表。但是,在 Nuget 包更新到更新版本之前,没有任何冲突。
Once a Nuget package was updated, however, only active Projects had their repositories listings updated. NuGet Package Restore chose to download just one version of the library - the first one it encountered in repositories.config, which was the older one. The compiler and IDE proceeded as though it chose the newer one. The result was a run-time exception saying the DLL was missing.
但是,一旦 Nuget 包更新,只有活动的项目才会更新其存储库列表。NuGet Package Restore 选择只下载库的一个版本 - 它在 repositories.config 中遇到的第一个版本,这是旧版本。编译器和 IDE 继续运行,就好像它选择了较新的一样。结果是一个运行时异常,说 DLL 丢失。
The answer obviously is to delete any lines from this file that referenced Projects that aren't in your Solution.
答案显然是从该文件中删除引用不在您的解决方案中的项目的任何行。
回答by Sofia Khwaja
In my case, I was able to find issue with ScriptManager by setting Debug=true in web.config file
就我而言,我能够通过在 web.config 文件中设置 Debug=true 来找到 ScriptManager 的问题
回答by killer
I answered too late but it has worked in my case.If you are facing this issue in your project please add the following line in your web.config :
我回答得太晚了,但它在我的情况下有效。如果您在项目中遇到此问题,请在您的 web.config 中添加以下行:
<compilation batch="false" >
This worked in my case. If you already have compilation tag in your web.config then add only batch="false" property to it.
这在我的情况下有效。如果您的 web.config 中已经有编译标记,则只向其中添加 batch="false" 属性。
回答by Rizwan
You can enable NuGet packages and update you dlls. so that it work. or you can update the package manually by going through the package manager in your vs if u know which version you require for your solution.
您可以启用 NuGet 包并更新您的 dll。以便它工作。或者,如果您知道解决方案需要哪个版本,您可以通过 vs 中的包管理器手动更新包。
回答by Rob
I got this after downgrading a project from .net 4.5 to .net 3.5.
在将项目从 .net 4.5 降级到 .net 3.5 后,我得到了这个。
To resolve I had to go in to the project - properties - settings window and delete all my settings, save the project, exit and restart visual studio, go back into project - properties -settings window and re-enter all my settings and their default values
要解决我必须进入项目 - 属性 - 设置窗口并删除我的所有设置,保存项目,退出并重新启动 Visual Studio,返回到项目 - 属性 - 设置窗口并重新输入我的所有设置及其默认值价值观
回答by Rajnish
Even I have experience some more strange things, I can see there is no dll in GAC from where the dll is loading but windows > Module shows system.dll version=4.0.0.0 loaded
即使我遇到了一些更奇怪的事情,我可以看到加载 dll 的 GAC 中没有 dll 但 windows > 模块显示 system.dll version=4.0.0.0 已加载
回答by user3493436
This worked for me. Go to Project->Propertied->Target Frawork->Change frame work like 3.5 to 4.0
这对我有用。转到 Project->Properted->Target Frawork->Change frame work like 3.5 to 4.0
回答by Alexis Wilke
I had the problem under Linux and I needed to install those. I don't know which one actually fixed the problem, but that error was gone after that:
我在 Linux 下遇到了问题,我需要安装它们。我不知道哪一个真正解决了问题,但在那之后错误消失了:
apt-get install mono-utils mono-runtime-sgen mono-runtime-common \
mono-runtime-boehm mono-runtime-dbg mono-xbuild
回答by JoeKreydt
I've seen this a couple times, and it is usually fixed by running a repair on .NET Framework (whichever version the application is trying to use).
我已经见过几次了,它通常通过在 .NET Framework(无论应用程序尝试使用哪个版本)上运行修复来修复。

