我有另一个这些“无法加载文件或程序集或其依赖项之一”的问题。

附加信息:无法加载 文件或程序集 “Microsoft.Practices.Unity, Version = 1.2.0.0、文化=中立, 都31 bf3856ad364e35”或 它的依赖项之一。在位于 程序集的显式定义可以 不匹配程序集引用。 (异常来自HRESULT: 0x80131040)

我不知道是什么导致了这种情况,也不知道如何调试它来找到原因。

我在我的解决方案目录.csproj文件中做了一个搜索,我有Unity的每个地方:

参考 包括= " Microsoft.Practices.Unity, Version = 2.0.414.0、文化=中立, 都31 bf3856ad364e35, processorArchitecture = MSIL”

在我的任何项目中都找不到任何与1.2.0.0相反的参考。

我该怎么解决这个问题呢?


当前回答

TLDR; 我的解决方案是在visual studio中恢复默认设置。


我在visual studio 2019社区版上,我在不同的项目中遇到了同一个dll文件的问题,我没有接触过。

After trying out all the answers in this question (as of 2020-07-22 7:13UTC) I decided to repair visual studio installation (backed up my settings beforehand). After installation opened the solutions that had the problem and the problem was gone. After that imported my settings that and the problem came back!! So without repairing visual studio installation again (which takes a few minutes + one restart) I've simply restored VS default settings and then it works. If I end up having time to investigate, I'll edit the answer and pinpoint the underlaying issue

其他回答

我一直在visual studio 2015的web表单项目上得到这个错误。我关闭了VisualStudio,我杀死了ScriptedSandbox64.exe, Microsoft.VsHub.Server.HttpHostx64.exe, Microsoft.VsHub.Server.HttpHostx.exe *32, Microsoft.VisualStudio.Web.Host.exe *32进程,它似乎有助于解决问题。

我的解决方案是:

我有一个三层应用程序,我忘记将DLL复制到IIS的正确路径。只要复制到正确的位置,它就为我工作了。

下面的方法对我很有效。

删除临时文件C:\Windows\Microsoft.NET\Framework\v4.0.30319\临时ASP. net网络文件 关闭VSTS,然后重新打开 删除和添加相同的dll(注意:您添加了相同的匹配版本)

在我的情况下,bin文件夹是一个名为Unity的非引用dll。MVC3,我试图在visual studio中搜索任何参考,没有成功,所以我的解决方案很简单,从bin文件夹中删除那个dll。

对我来说,这是一个奇怪的解决方案,但我刚刚从源代码控制中获取了这个解决方案。

正在得到此错误,检查了上面的大部分答案,然后删除解决方案并从源代码控制中重新拉出解决方案。

工作。

只会适用于少数人,但我想我是少数人之一,所以会有更多。不知道第一次发生了什么,但不知怎的,当我把它们拉过去时,一些程序集肯定有一些问题。

基本上就是把它关掉再打开。