简体   繁体   English

无法加载文件或程序集或其依赖项之一

[英]Could not load file or assembly or one of its dependencies

I'm having another of these "Could not load file or assembly or one of its dependencies" problems.我遇到了另一个“无法加载文件或程序集或其依赖项之一”的问题。

Additional information: Could not load file or assembly 'Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.附加信息:无法加载文件或程序集“Microsoft.Practices.Unity,Version=1.2.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference.找到的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (HRESULT 异常:0x80131040)

I have no idea what is causing this or how I could debug it to find the cause.我不知道是什么原因造成的,也不知道如何调试它来找到原因。

I've done a search in my solution catalogs.csproj files, and every where I have Unity I have:我在我的解决方案 catalogs.csproj 文件中进行了搜索,在我拥有 Unity 的每个地方我都有:

Reference Include="Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" Reference Include="Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"

Can't find any reference anywhere which goes against 1.2.0.0 in any of my projects.在我的任何项目中都找不到任何违反 1.2.0.0 的参考。

Any ideas how I should go about solving this?我应该如何解决此问题的任何想法 go?

  1. Check if you are referencing an assembly which in turn referencing an old version of unity.检查您是否正在引用一个程序集,而该程序集又引用了旧版本的统一。 For example let's say you have an assembly called ServiceLocator.dll which needs an old version of Unity assembly, now when you reference the ServiceLocator you should provide it with the old version of Unity, and that makes the problem.例如,假设您有一个名为ServiceLocator.dll的程序集,它需要旧版本的 Unity 程序集,现在当您引用ServiceLocator您应该为它提供旧版本的 Unity,这就产生了问题。

  2. May be the output folder where all projects build their assemblies, has an old version of unity.可能是所有项目构建其程序集的输出文件夹,具有旧版本的统一。

You can use FusLogVw to find out who is loading the old assemblies, just define a path for the log, and run your solution, then check (in FusLogvw) the first line where the Unity assembly is loaded, double click it and see the calling assembly, and here you go.您可以使用FusLogVw找出谁正在加载旧程序集,只需为日志定义一个路径,然后运行您的解决方案,然后检查(在 FusLogvw 中)加载 Unity 程序集的第一行,双击它并查看调用组装,然后开始。

Open IIS Manager打开 IIS 管理器

Select Application Pools选择应用程序池

then select the pool you are using然后选择您正在使用的池

go to advanced settings (at right side)进入高级设置(在右侧)

Change the flag of Enable 32-bit application false to true.将启用 32 位应用程序 false 的标志更改为 true。

For me, none of the other solutions worked (including the clean/rebuild strategy).对我来说,其他解决方案都不起作用(包括清理/重建策略)。 I found another workaround solution which is to close and re-open Visual Studio .我找到了另一种解决方法,即关闭并重新打开 Visual Studio

I guess this forces Visual Studio to re-load the solution and all the projects, rechecking the dependencies in the process.我想这会迫使 Visual Studio 重新加载解决方案和所有项目,重新检查流程中的依赖项。

Try to clean Debug and Release folders in your solution.尝试清理解决方案中的 Debug 和 Release 文件夹。 Then remove and add unity again.然后删除并再次添加统一。

At 99% the Could not load file or assembly or one of its dependencies problem is caused by dependencies! 99% 的无法加载文件或程序集或其依赖项问题之一是由依赖项引起的! I suggest you follow this steps:我建议您按照以下步骤操作:

  1. Download Dependency Walker from http://www.dependencywalker.com/http://www.dependencywalker.com/下载Dependency Walker

  2. Launch Dependency Walker and open the dll (in my case NativeInterfaces.dll )启动Dependency Walker并打开 dll(在我的情况下NativeInterfaces.dll

  3. You can see one or more dll with the error in red Error opening file...您可以看到一个或多个带有红色错误的dll错误打开文件...

  1. It means that this dll is missing in your system;这意味着您的系统中缺少此 dll; in my case the dll name is MSVCR71.DLL在我的情况下,dll 名称是MSVCR71.DLL

  2. You can download missings dll from google and copy in right path (in my case c:\\windows\\system32 )您可以从 google 下载缺少的 dll 并复制到正确的路径中(在我的情况下是c:\\windows\\system32

  3. At this point, you must register the new dll in the GAC (Global Assembly Cache): open a DOS terminal and write:此时必须在GAC(Global Assembly Cache)中注册新的dll:打开DOS终端,写入:

     cd \\Windows\\System32 regsvr32 /i msvcr71.dll
  4. Restart your application重新启动您的应用程序

Despite the original question being posted five years ago, the problem still persists and is rather annoying.尽管最初的问题是五年前发布的,但问题仍然存在并且相当烦人。

The general solution is thorough analysis of all referenced assemblies to understand what's going wrong.一般的解决方案是对所有引用的程序集进行彻底分析,以了解出了什么问题。 To make this task easier I made a tool (a Visual Studio extension) which allows selecting a .NET assembly (a .dll or .exe file) to get a graph of all the referenced assemblies while highlighting conflicting or missing references.为了使这个任务更容易,我制作了一个工具(一个 Visual Studio 扩展),它允许选择一个 .NET 程序集(一个.dll.exe文件)来获取所有引用程序集的图形,同时突出显示冲突或丢失的引用。

The tool is available in Visual Studio Gallery: https://marketplace.visualstudio.com/vsgallery/051172f3-4b30-4bbc-8da6-d55f70402734该工具在 Visual Studio Gallery 中可用: https : //marketplace.visualstudio.com/vsgallery/051172f3-4b30-4bbc-8da6-d55f70402734

Example of output:输出示例: 在此处输入图片说明

Microsoft Enterprise Library (referenced by .NetTiers) was our problem, which was in turn referencing an older version of Unity. Microsoft Enterprise Library(由 .NetTiers 引用)是我们的问题,它又引用了旧版本的 Unity。 In order to solve the problem we used the following binding redirection in the web.config:为了解决这个问题,我们在 web.config 中使用了以下绑定重定向:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Practices.Unity.Configuration" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Alternatively, you may want to just update the Enterprise Library to the latest version.或者,您可能只想将企业库更新到最新版本。

Following worked for me.以下为我工作。

  • Remove Temporary Files C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files删除临时文件 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files
  • Close VSTS and Open Again关闭 VSTS 并再次打开
  • Remove and Add the same DLLs (Note: you add the same matching versions)删除和添加相同的 DLL(注意:您添加相同的匹配版本)

Check the Web.config/App.config file in your project.检查项目中的 Web.config/App.config 文件。 See if the version numbers are correct.查看版本号是否正确。

<bindingRedirect oldVersion="X.X.X.X-X.X.X.X" newVersion="X.X.X.X" />

This worked for me.这对我有用。

截图 In solution explorer right click on project (not solution), in build tab choose Platform target : "Any CPU".在解决方案资源管理器中右键单击项目(不是解决方案),在构建选项卡中选择平台目标:“任何 CPU”。

Juntos answer is correct but you should also consider: Juntos 的回答是正确的,但您还应该考虑:

For the unity v2.1.505.2 different AssemblyVersion and AssemblyFileVersion attributes are specified:对于 unity v2.1.505.2 ,指定了不同的AssemblyVersionAssemblyFileVersion属性:

在此处输入图片说明

AssemblyFileVersion is used by the NuGet but CLR does not care about it! NuGet 使用了AssemblyFileVersion ,但 CLR 并不关心它! CLR is going to use only AssemblyVersion ! CLR 将只使用AssemblyVersion

So your redirects should be applied to a version that specified in AssemblyVersion attribute.因此,您的重定向应应用于在AssemblyVersion属性中指定的版本。 So 2.1.505.0 should be used所以应该使用2.1.505.0

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
 <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.505.0" newVersion="2.1.505.0" />
</dependentAssembly>
</assemblyBinding>

See also: What are differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion?另请参阅: AssemblyVersion、AssemblyFileVersion 和 AssemblyInformationalVersion 之间有什么区别?

I also got this terrible error and found a solution for this...我也遇到了这个可怕的错误,并为此找到了解决方案......

  1. Right Click on the Solution name右键单击解决方案名称
  2. Click Clean Solution单击清洁解决方案
  3. Restart Visual Studio重新启动 Visual Studio
  4. Goto project Properties >> Build转到项目属性>>构建
  5. Change Configuration to Release更改配置发布
  6. Start Debugging (F5)开始调试 (F5)

1) , 2) 1) , 2)

右键单击解决方案名称

4) , 5) 4) , 5)

更改配置以发布

Hope this will help you also.希望这也能帮助你。

Not sure if this might help.不确定这是否有帮助。

Check that the Assembly name and the Default namespace in the Properies in your asemblies match.检查程序集中的属性中的程序集名称和默认命名空间是否匹配。 This resolved my issue which yielded the same error.这解决了我的问题,产生了同样的错误。

  • Goto : Solution -> Package转到:解决方案->
  • Click on Advanced Tab (Find below the page)单击高级选项卡(在页面下方查找)
  • Add your dll to additional assemblies(this way we can add external dlls in sharepoint).将您的dll添加到其他程序集(这样我们可以在 sharepoint 中添加外部 dll)。

就我而言,bin 文件夹中是一个名为 Unity.MVC3 的非引用 dll,我尝试在 Visual Studio 中搜索对此的任何引用,但没有成功,因此我的解决方案非常简单,只需从 bin 文件夹中删除该 dll。

I had the same problem i solved it via the instructions below:我遇到了同样的问题,我通过以下说明解决了它:

  1. open tools menu and select option打开工具菜单并选择选项
  2. in options, window go to Projects and Solutions/Web Projects在选项中,窗口转到项目和解决方案/Web 项目
  3. check use the 64bit version of IIS ...检查use the 64bit version of IIS ...

在此处输入图片说明

Thanks Riddhi M. Following worked for me.谢谢 Riddhi M. 以下为我工作。

Remove Temporary Files C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files Close VSTS and Open Again Remove and Add the same DLLs (Note: you add the same matching versions)删除临时文件 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files Close VSTS and Open Again Remove and Add the same DLLs (注意:你添加了相同的匹配版本)

Following worked for me.以下为我工作。

  • Remove Temporary Files C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files删除临时文件 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files
    • then right click on Temporary Asp.net Files>properties>security and give total control access to IIS and to all user runing my project然后右键单击 Temporary Asp.net Files>properties>security 并授予对 IIS 和所有运行我的项目的用户的完全控制访问权限

这个问题发生在我身上,当父库期望编译“x64”时,我的一个依赖库正在编译带有“任何 CPU”的 DLL。

You say you have a lot of projects in your solution ... well, start with one near the top of the build order.你说你的解决方案中有很多项目......好吧,从一个靠近构建顺序顶部的项目开始。 Get that one to build and once you figure it out you can apply the same fix to the rest of them.建立一个,一旦你弄清楚了,你就可以对其余的应用相同的修复程序。

Honestly, you probably just need to refresh your reference.老实说,您可能只需要刷新您的参考。 It sounds like you either updated your version and didn't update the references, or it's a relative path issue if you keep your solution in source control.听起来您要么更新了版本但没有更新引用,要么如果您将解决方案保留在源代码管理中,则这是一个相对路径问题。 Just verify your assumptions, and re-add the reference.只需验证您的假设,然后重新添加引用即可。

You have to delete Your appname.dll file from your output folder.您必须从输出文件夹中删除您的 appname.dll 文件。 Cleanup Debug and Release folders.清理调试和发布文件夹。 Rebuild and copy to output folder regenerated dll file.重建并复制到输出文件夹重新生成的 dll 文件。

I "Set as Startup Project" the unloaded/unfound library/project.“设置为启动项目”卸载/未找到的库/项目。

Then deployed it.然后部署了它。

It worked!它奏效了!

I think it couldn't found the .dll because it was not in the assembly at first.我认为它无法找到 .dll,因为它最初不在程序集中。

if you are getting this error message by opening an application on you windows xp it mean first you have installed that app due to its not working without net framework 4 and service pack 3 .如果您通过在 Windows xp 上打开应用程序收到此错误消息,则意味着您首先安装了该应用程序,因为它在没有 net framework 4 和 service pack 3 的情况下无法运行。 you installed both and again you are getting this error so you should reinstall that app again but first uninstall from add and remove您一次又一次地安装了此错误,因此您应该再次重新安装该应用程序,但首先从添加和删除中卸载

if this not work please dont abuse me .如果这不起作用,请不要虐待我。 i am also a junior我也是小学生

另一个可能的原因:确保您没有意外地在项目属性中为这两个项目指定了相同的程序集名称。

My solution for .NET 4.0, using Enterprise Library 5, was to add a reference to:我使用企业库 5 的 .NET 4.0 解决方案是添加对以下内容的引用:

Microsoft.Practices.Unity.Interception.dll Microsoft.Practices.Unity.Interception.dll

Look out for conflicting references.留意相互冲突的引用。 Even after a clean and rebuild, conflicting references will still cause a problem.即使在清理和重建之后,冲突的引用仍然会导致问题。 My problem was between AForge and Accord.我的问题是在 AForge 和 Accord 之间。 I removed both of the references, and re-added the references re-choosing the particular reference (particular to my case, just Accord).我删除了两个引用,并重新添加了引用,重新选择了特定的引用(特别是我的情况,只是 Accord)。

对我来说,在没有 Unity C# Projects Checkmark 的情况下重建 Unity 游戏有效。

In my case, none of the proposed answer worked.就我而言,建议的答案都没有奏效。

Here is what worked for me:这是对我有用的:

  1. Remove the reference删除引用
  2. Rename the DLL重命名 DLL
  3. Import the reference again再次导入引用

The second step was important apparently as it did not work without it.第二步显然很重要,因为没有它它就无法工作。

Try checking if the "Copy to Local" property for the reference is set to true and the specific version is set to true.尝试检查引用的“复制到本地”属性是否设置为 true 并且特定版本是否设置为 true。 This is relevant for applications in Visual Studio.这与 Visual Studio 中的应用程序相关。

I had this today, and in my case the issue was very odd:我今天遇到了这个问题,就我而言,问题很奇怪:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.1.0" newVersion="3.1.0.0" />
  </dependentAssembly>0.

Note the stray characters at the end of the XML - somehow those had been moved from the version number to the end of this block of XML!请注意 XML 末尾的杂散字符 - 不知何故,这些字符已从版本号移动到此 XML 块的末尾!

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
  </dependentAssembly>

Changed to the above and voila!更改为以上,瞧! Everything worked again.一切都恢复了。

Clean the solution and then right click on the project and select Package清理解决方案,然后右键单击项目和 select Package

Here increment the Assembly and Assembly file version and rebuild.这里增加AssemblyAssembly file版本并重建。

在此处输入图像描述

If that does not work,如果这不起作用,

1 - Open the solution in file Explorer. 1 - 在文件资源管理器中打开解决方案。

2 - Close Visual Studio. 2 - 关闭 Visual Studio。

3 - Remove all bin and obj folders. 3 - 删除所有binobj文件夹。

4 - Reopen the project and build it. 4 - 重新打开项目并构建它。

Okay this may sound very stupid, but heres how I solved the issue after trying out every other solution and spending a night on this stupid thing. 好吧,这听起来可能非常愚蠢,但继续尝试其他所有解决方案并在这个愚蠢的事情上过夜后,我是如何解决这个问题的。

I was getting the same error with some DLL missing from Bin Folder. 我从Bin文件夹中丢失了一些DLL时遇到了同样的错误。 I tried to delete , get back up everything from Team Foundation Server but didn't work. 我试图删除,从Team Foundation Server备份所有内容但没有工作。 Got a copy of Bin folder from my office-matelocal machine, and replaced it. 从我的office-matelocal机器获得了Bin文件夹的副本,并将其替换。 It didn't work either. 它也没用。 At last, I manually FTPed server, got the copy of DLL which was showing up as missing, and then it started showing up that next file in the file list sequence is missing. 最后,我手动FTP服务器,获得了显示为丢失的DLL副本,然后它开始显示文件列表序列中的下一个文件丢失。

So I ftped server Got all Bin Folder, Manually replaced each file one by one. 所以我ftped服务器得到了所有Bin文件夹,手动逐个替换每个文件。 (Not Ctrl + All and replace.. I tried : it didn't work.) And somehow it worked... (不是Ctrl + All并替换..我试过:它不起作用。)不知何故它起作用了......

My solution was:我的解决方案是:

I have a three-tier application and I forgot to copy the DLL also to the right path at IIS .我有一个三层应用程序,我忘记将 DLL 也复制到 IIS 的正确路径 Just after copied it to the right place it worked for me.将它复制到正确的位置后,它对我有用。

I kept getting this error on my web forms project in visual studio 2015. I shutdown Visual Studio and I killed the ScriptedSandbox64.exe, Microsoft.VsHub.Server.HttpHostx64.exe, Microsoft.VsHub.Server.HttpHostx.exe *32, Microsoft.VisualStudio.Web.Host.exe *32 processes and it seemed to help fix the issue.我在 Visual Studio 2015 中的 web forms 项目中不断收到此错误。我关闭了 Visual Studio 并杀死了 ScriptedSandbox64.exe、Microsoft.VsHub.Server.HttpHostx64.exe、Microsoft.VsHub.Server.HttpHostx.exe .VisualStudio.Web.Host.exe *32 个进程,它似乎有助于解决问题。

I do the following to work out which dependency cannot be found.我执行以下操作来确定找不到哪个依赖项。

Run regedit.exe and navigate to:运行 regedit.exe 并导航到:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion

Create the following:创建以下内容:

LogFailures set value to 1 (DWORD)
LogResourceBinds set value to 1 (DWORD)
LogPath (String) set value to C:\FusionLog\

Now run your program and wait for it to raise Could not load file or assembly or one of its dependencies .现在运行您的程序并等待它引发Could not load file or assembly or one of its dependencies

Using explorer, navigate to C:\FusionLog and there should be a folder containing logs for your program, showing which dependency is missing.使用资源管理器,导航到C:\FusionLog并且应该有一个包含程序日志的文件夹,显示缺少哪个依赖项。

Note: Some people use FUSLOGVW.exe, which is a viewer for these Fusion Logs.注意:有些人使用 FUSLOGVW.exe,它是这些 Fusion Logs 的查看器。 On my machine it can be found in multiple places, including:在我的机器上可以在多个地方找到它,包括:

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\x64\FUSLOGVW.exe

I had this problem, the mistake was actually very silly.我有这个问题,这个错误实际上很愚蠢。 I had specified the wrong location for the.dll file , after changing the location to correct location the loading happened correctly (answering so someone else don't make this mistake).我为 .dll 文件指定了错误的位置,在将位置更改为正确的位置后,加载正确发生(回答所以其他人不要犯这个错误)。

For me, it seems that Nuget wasn't playing nice with my project/solution.对我来说,Nuget 似乎对我的项目/解决方案不太好。 I used Nuget to install NewtonSoft.Json The project file seemed to reference it correctly, and when I R-clicked the dll name in Solution Explorer/Dependencies/Nuget, then clicked Properties, I found that the dll existed where properties said it should be. I used Nuget to install NewtonSoft.Json The project file seemed to reference it correctly, and when I R-clicked the dll name in Solution Explorer/Dependencies/Nuget, then clicked Properties, I found that the dll existed where properties said it should be .

I deleted the Nuget package and did R-click Project > Add > Reference and browsed to the dll in a packages directory when a former Nuget process had installed it, and then the Solution ran fine. I deleted the Nuget package and did R-click Project > Add > Reference and browsed to the dll in a packages directory when a former Nuget process had installed it, and then the Solution ran fine.

NOTES: this solution is quite aa hodge podge, starting with a Xamarin.iOS solution and adding a .netstandard project (which is where I had difficulty using Nuget).注意:这个解决方案是一个大杂烩,从 Xamarin.iOS 解决方案开始,并添加一个 .netstandard 项目(这是我在使用 Nuget 时遇到困难的地方)。 There is also a "portable" project in the solution.解决方案中还有一个“便携式”项目。 I inherited all this from a dev who has been gone for 3 years.我从一个已经离开 3 年的开发人员那里继承了这一切。 Ha ha.哈哈。

I have a C# Winforms project called SetTags with a large number of forms that I use Visual Studio 2013 to work on.我有一个名为 SetTags 的 C# Winforms 项目,其中包含大量 forms,我使用 Visual Studio 2013 进行处理。 After editing one of them and trying to build I got the error:在编辑其中一个并尝试构建后,我得到了错误:

Could not load file or assembly 'SetTags Version = 2.1.85.0, Culture=neutral,PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

The error also appeared when I tried to save the project or to close the form I had been working on.当我尝试保存项目或关闭我一直在处理的表单时,也会出现该错误。

I fixed the problem by removing a recently added radio button control and commenting out all references to it, then added the control again and uncommenting the code.我通过删除最近添加的单选按钮控件并注释掉对其的所有引用来解决问题,然后再次添加控件并取消注释代码。 This allowed me to save the form, and on closing restarting VS the problem had disappeared.这使我可以保存表单,并在关闭重新启动 VS 时问题消失了。

My Visual Studio environment has many occasional problems - Toolbox not showing or appearing only on VS startup, unrecognized custom controls when trying to view a form in Design mode - and it may be that I need to move on to a later VS version.我的 Visual Studio 环境偶尔会出现许多问题 - 工具箱不显示或仅在 VS 启动时出现,尝试在设计模式下查看表单时无法识别的自定义控件 - 可能是我需要转到更高的 VS 版本。

A strange fix for me, but I had just pulled this solution from source control.对我来说是一个奇怪的修复,但我刚刚从源代码管理中提取了这个解决方案。

Was getting this error, went through most of the answers above, and then deleted the solution and re-pulled the solution from source control.收到此错误,查看了上面的大部分答案,然后删除了解决方案并从源代码管理中重新提取了解决方案。

Worked.工作。

Will only apply to a few, but I guess I was one of the few so there will be more.只适用于少数人,但我想我是少数人之一,所以会有更多。 Not sure what happened the first time, but somehow some assemblies must have had some issues when I pulled them across.不知道第一次发生了什么,但不知何故,当我把它们拉过来时,某些组件一定有一些问题。

Essentially turn it off and on again.基本上将其关闭并再次打开。

I wasted a few frustrating hours on this problem too.我也在这个问题上浪费了几个令人沮丧的时间。 We had to update our version of the .NET Framework, and started getting multiple “Could not load file or assembly or one of its dependencies” for several DLLs that had not been changed for years.我们不得不更新我们的 .NET 框架版本,并开始为几个多年未更改的 DLL 获取多个“无法加载文件或程序集或其依赖项之一”。 Strangely, the versions being searched for in the error messages were all extremely old.奇怪的是,在错误消息中搜索的版本都非常旧。 For example, it was searching for Newtonsoft.Json version 6.0.0 while we had been using 8.0.1 for years.例如,它正在搜索 Newtonsoft.Json 版本 6.0.0,而我们多年来一直使用 8.0.1。

Reverting to these ancient versions was not an option, and anyway there were a bunch of bindingRedirect elements in our web.config file that were supposed to redirect calls to old DLLs to the new ones.恢复到这些旧版本不是一种选择,无论如何,我们的 web.config 文件中有一堆bindingRedirect元素,它们应该将对旧 DLL 的调用重定向到新的 DLL。 Rolling back the .NET version made the errors go away, but we needed the new version.回滚 .NET 版本使错误 go 消失,但我们需要新版本。 What is going on?到底是怎么回事?

The <runtime> element in our web.config file contained the element:我们的 web.config 文件中的<runtime>元素包含以下元素:

<assemblyBinding appliesTo="v2.0.50727"
    xmlns="urn:schemas-microsoft-com:asm.v1">

The dependentAssembly elements that seemed to be ignored were contained in that.似乎被忽略的dependentAssembly元素包含在其中。

The culprit was the appliesTo attribute.罪魁祸首是appliesTo属性。 It meant the bindingRedirect applies only to .NET version 2.0.50727.这意味着bindingRedirect仅适用于 .NET 版本 2.0.50727。 When we updated the .NET Framework version, all our bindingRedirect elements were ignored.当我们更新 .NET 框架版本时,我们所有的 bindingRedirect 元素都被忽略了。

The solution in our case was to remove the appliesTo attribute entirely.在我们的案例中,解决方案是完全删除appliesTo属性。

Your project's csproj file must contain a package reference of Microsoft.Practices.Unity and this could not be found in the global-packages folder (%userprofile%.nuget\packages), running dotnet restore fixes the issue您的项目的 csproj 文件必须包含 Microsoft.Practices.Unity 的 package 引用,并且在 global-packages 文件夹 (%userprofile%.nuget\packages) 中找不到此文件,运行dotnet restore可解决此问题

Step 1: Remove the Existing Reference Step 2: Clean Solution Step 3: Add project Reference again.第 1 步:删除现有参考 第 2 步:清理解决方案 第 3 步:再次添加项目参考。

and its done.并完成。 :) :)

TLDR; TLDR; the solution for me was to restore default settings in visual studio.我的解决方案是在 Visual Studio 中恢复默认设置。


I'm on visual studio 2019 community edition and I had this issue for same dll file across different projects that I didn't touch.我在 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).在尝试了这个问题的所有答案后(截至 2020-07-22 7:13UTC),我决定修复 Visual Studio 安装(事先备份了我的设置)。 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.之后导入我的设置,问题又回来了。因此,无需再次修复 Visual Studio 安装(这需要几分钟 + 一次重启),我只是恢复了 VS 默认设置,然后它就可以工作了。 If I end up having time to investigate, I'll edit the answer and pinpoint the underlaying issue如果我最终有时间进行调查,我将编辑答案并查明潜在问题

Tried closing and re-opening VS as suggested but it didn't work out.尝试按照建议关闭并重新打开 VS,但没有成功。

I had to change from MIXED PLATFORMS to ANY CPU .我不得不从 MIXED PLATFORMS更改为 ANY CPU

在此处输入图像描述

i used the amazing tool "Fusion++" https://github.com/awaescher/Fusion我使用了神奇的工具“Fusion++” https://github.com/awaescher/Fusion

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集&#39;&#39;或其依赖项之一 - Could not load file or assembly '' or one of its dependencies 无法加载文件或程序集及其依赖项之一 - Could not load file or assembly and one of its dependencies 无法加载文件或程序集或其依赖项之一 - Could not load file or assembly or one of its dependencies 无法加载文件或程序集或其依赖项之一 - could not load file or assembly or one of its dependencies 无法加载文件或程序集“WebGrease”或其依赖项之一 - Could not load file or assembly 'WebGrease' or one of its dependencies 无法加载文件或程序集“ EfTidyNet”或其依赖项之一 - Could not load file or assembly 'EfTidyNet' or one of its dependencies 错误原因:无法加载文件或程序集”或其依赖项之一 - What cause to error: Could not load file or assembly '' or one of its dependencies 无法加载文件或程序集“ tesseract.dll”或其依赖项之一 - Could not load file or assembly 'tesseract.dll' or one of its dependencies 无法加载文件或程序集“ __App_Code”或其依赖项之一 - Could not load file or assembly '__App_Code' or one of its dependencies 无法加载文件或程序集或其依赖项之一,错误消息已更改 - Could not load file or assembly or one of its dependencies, error message changing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM