HRESULT:0x80131040:找到的程序集的清单定义与程序集引用不匹配
程序集引用不匹配
找到的程序集的清单定义与通过 ncover 运行 nunit 时获取此信息的 。 任何想法?
The located assembly's manifest definition does not match the assembly reference
getting this when running nunit through ncover. Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
我测试了上面的所有解决方案,但对我来说不起作用,
经过考虑各种情况后发现问题出在其他地方,真是尴尬。
我在不同文件夹上的同一个项目有两个不同的分支,问题来自另一个分支。
我在两个分支上更新了 nuget 包(对于错误页面上提到的包),问题解决了!
I tested All the solutions above but didn't work out for me,
after consideration all situations found out the problem is somewhere else, it was so awkward.
I have two different branches for the same project on different folders, the problem was from the other branch.
I updated nuget packages (for the mentioned package on error page) on both branches and the problem solved!
对我来说,问题出在应用程序文件版本中,它是 3.3.1,我正在将新版本构建为 20.0.1,当将版本重置回相同值时,它工作正常。
For me the problem was in the app file version, it was 3.3.1 and i was building the new one as 20.0.1, when reset the version back to the same value it worked fine.
我在设计器中工作时遇到此错误。 我一直在 VS 2012 中进行开发,但在过去几天“升级”到了 2017。 解决方案是关闭并重新打开 VS。
它可能与我看到的报告的错误有关 其他地方,参考管理器在哪里不起作用? 在这种情况下,尝试在解决方案资源管理器中添加引用时会遇到以下错误消息:
是关闭解决方案,在 VS2012 中重新打开,添加引用,关闭 2012 并重新打开 2017。可笑的是 2017 应该已经发布了如此明显的错误。
I got this error when working in the Designer. I had been developing in VS 2012, but "upgraded" to 2017 over the past couple days. Solution was to close and reopen VS.
It may be related to a bug which I've seen reported elsewhere, where the Reference Manager does not work? In that situation, the following error message is encountered when trying to add a reference in the Solution Explorer:
My workaround was to close the solution, reopen in VS2012, add the reference, close 2012 and reopen 2017. Ridiculous that 2017 should have been released with such an obvious bug.
只需检查您的 webconfig 文件并删除此代码:-
Just Check your webconfig file and remove this code :-
当我更新 web.config 而不更新所有引用的 dll 时,就发生了这种情况。
使用正确的 diff 过滤器(注意 Meld 的默认目录比较过滤器忽略二进制文件),可以识别差异,复制文件,一切正常。
This happened to me when I updated web.config without updating all referenced dlls.
Using proper diff filter (beware of Meld's default directory compare filter ignoring binaries) the difference was identified, files were copied and everything worked fine.
我只需从项目中删除 settings.lic 文件并开始工作!
I just delete settings.lic file from project and start working!
这里只是另一个例子。 第一次在 VS2010/.NET 4 下将 XML 文件反序列化为对象时,我从托管调试助手中遇到了此错误。在构建后事件中生成包含对象类的 DLL(通常是 Microsoft 风格的东西)。 在同一解决方案中的多个项目中运行得很好,但在另一个项目中执行此操作时出现了问题。 错误文本:
由于这里的一些答案表明平台不匹配,我注意到 3 个项目和解决方案选择了“混合平台”配置,并且 3 个项目是针对 x86 而不是 AnyCPU 编译的。 我没有特定于平台的代码(尽管一些供应商提供的 DLL 依赖于一些 x86 库)。 我将所有出现的 x86 替换为 AnyCPU,如下所示:
然后项目将构建,但所有运行或调试代码的选项将显示为灰色。 重新启动 VS 没有帮助。
为了以防万一,我使用 git 恢复了对 x86 库的引用,但为我编译的所有代码保留了 AnyCPU。
以下 F5 或开始调试按钮灰显Winform 应用程序? 我卸载并重新加载了启动项目(这也是最初出现问题的项目)。
之后,一切都恢复正常:程序正常运行,没有出现最初的错误。
请参阅http://www.catb.org/jargon/html/R /rain-dance.html , http://www .catb.org/jargon/html/V/voodoo-programming.html 或 http://www.catb.org/jargon/html/I/incantation.html 和链接。
Just another case here. I had this error from Managed Debugging Assistant on the first time deserializing a XML file into objects under VS2010/.NET 4. A DLL containing classes for the objects is generated in a post-build event (usual Microsoft style stuff). Worked very well for several projects in same solution, problem appeared when doing that in one more of the projects. Error text:
Since some answers here suggested a platform mismatch, I noticed that 3 projects and the solution had "mixed platforms" configuration selected, and 3 projects were compiled for x86 instead of AnyCPU. I have no platform-specific code (though some vendor-provided DLLs rely on a few x86 libraries). I replaced all occurrences of x86 into AnyCPU with this:
Then the project would build but all options to run or debug code would be greyed out. Restarting VS would not help.
I reverted with git the references to the x86-library, just in case, but kept AnyCPU for all the code I compile.
Following F5 or Start Debugging Button is Greyed Out for Winform application? I unloaded and reloaded the starting project (it was also the one where the initial problem appeared in the first place).
After that, everything fell back into place: the program works without the initial error.
See http://www.catb.org/jargon/html/R/rain-dance.html , http://www.catb.org/jargon/html/V/voodoo-programming.html or http://www.catb.org/jargon/html/I/incantation.html and links there.
如果您在尝试向 Visual Studio 添加组件时遇到此错误,-
Microsoft.VisualStudio.TemplateWizardInterface
-(在尝试安装奇怪的开发工具后)请考虑此解决方案(由 larocha 提供(谢谢,无论您是谁) )):
Microsoft.VisualStudio.TemplateWizardInterfac
e”来源:http://webclientguidance.codeplex.com/workitem/15444< /a>
If you got this error trying to add a component to Visual Studio,-
Microsoft.VisualStudio.TemplateWizardInterface
- (after trying to install weird development tools)consider this solution(courtesy of larocha (thanks, whoever you are)):
Microsoft.VisualStudio.TemplateWizardInterfac
e"<dependentAssembly>
<!-- assemblyIdentity name="Microsoft.VisualStudio.TemplateWizardInterface" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" / -->
<bindingRedirect oldVersion="0.0.0.0-8.9.9.9" newVersion="9.0.0.0" />
</dependentAssembly>
source: http://webclientguidance.codeplex.com/workitem/15444
我的 WPF 项目引用了 3 个自定义 dll。 我更新了其中之一,删除了引用并将引用添加到了新的 dll 中。 它还在引用的属性中显示了正确的版本号。 它正在重建,没有错误。
但是当应用程序运行时,出现故障“定位程序集的清单..”,提到旧版本。
在搜索了几个小时的解决方案并阅读了几个这样的线程之后,我想起了其他 dll。
其他 dll 之一正在引用旧版本,这就是发生故障的原因。 重建第二个 dll 并在我的 WPF 项目中重新创建两个引用后,故障消失了。
不要忘记检查您的其他 dll!
My WPF project referenced 3 custom dlls. I updated one of them, deleted the reference and added the reference to the new dll. It also showed the correct version number in the properties of the reference. It was rebuilding without an error.
But when the application was running, the failure "The located assembly's manifest .." occured, mentioning the old version.
After searching for a solution for hours and reading couple of threads like this, I remembered the other dlls.
One of the other dlls was referencing the old version, and that's why the failure occured. After rebuilding the 2nd dll and recreating both references in my WPF project, the failure was gone.
Don't forget to check your other dlls!
我在一个 web api 项目中遇到了这个问题。
Api 项目使用版本 3 的库的 nuget 包。其中一个引用的程序集表示 X 使用版本 2 的同一 nuget 包的旧版本。
每当构建引用的程序集或重建引用 X 的任何其他项目时,api项目的程序集已更新为较低版本。 并收到此程序集引用错误。
重建有效,但就我而言,我想要一个长期的解决方案。
我使程序集引用相同版本的 nuget 包。
I ran into this issue in a web api project.
Api project was using a nuget package of a library with version 3. And one of the referenced assemblies say X was using older version of the same nuget package with version 2.
Whenever referenced assembly is built or any other project referencing X is rebuilt, api project's assemblies gets updated with lower version. And got this assembly reference error.
Rebuild works but in my case I wanted a long term solution.
I made the assemblies reference same version of nuget package.
我遇到了找不到 PayPal 程序集的问题,这是因为我将我的解决方案命名为 PayPal。 我确信这不会是任何人的答案,但我想我还是会分享它: C# ASP.NET MVC PayPal 未找到程序集
I had the issue where it wouldn't find the PayPal assembly and it was because I had named my solution PayPal. I'm sure this won't be the answer for anyone but thought I'd share it anyway: C# ASP.NET MVC PayPal not finding assembly
就我而言,这是由于 WebGrease 导致的。 我将其更新到最新版本(使用 NuGet),但它与依赖项冲突。 我在 web.config 中手动添加了以下代码,它非常有用。
请注意,我的解决方案仅在错误与 WebGrease 相关时才有效。 错误代码将保持不变。 另外,您需要相应地更改 oldVersion 和 newVersion 中的版本。
In my case it was happening because of WebGrease. I updated it to the latest version (using NuGet) but it was conflicted with the dependencies. I manually added the below code in web.config and it worked as a charm.
Please note my solution will only work when the error is related to WebGrease. The error code will remain the same. Also, you need to change the version in oldVersion and newVersion accordingly.
在我的特定情况下,我得到这个结果是在 VBScript 中完成的
CreateObject
。在我的案例中,原因是 GAC 中的程序集版本比我编译的版本更旧。 (为了解决之前的问题,我在 GAC 中安装了该程序集)。
因此,如果您正在使用 COM 可见类,那么请确保在使用 RegASM 注册新程序集之前从 GAC 中删除旧版本的程序集。
In my particular situation, I got this as a result of a
CreateObject
done in VBScript.The cause in my case was a version of the assembly that resided in the GAC, that was older than the one I had compiled. (trying to solve an earlier problem, I installed the assembly in the GAC).
So, if you're working with COM visible classes, then be sure you remove older versions of your assembly from the GAC, before registering your new assembly with RegASM.
通过共享文件夹从不同计算机访问项目文件时,我遇到了类似的问题。 就我而言,清理+重建没有帮助。 必须从输出目录中删除 bin 和对象文件夹。
I ran into similar problems when accessing the project files from different computers via a shared folder. In my case clean + reabuild did not help. Had to delete the bin and objects folders from the output directory.
很晚了,但我想分享我们对这个问题的解决方案(这个问题在 2023 年仍然存在)。 我们使用的是 Visual Studio 2022。
同样,这是我们收到的错误:
该问题称为DLL Hell,需要很长时间才能解决。 希望我的回答可以缩短您的时间。
DLL Hell 是指动态链接库 (DLL) 存在冲突或兼容性问题的情况。 DLL 是包含可由多个程序同时使用的代码和资源的文件,允许代码重用和模块化编程。
当系统上的不同应用程序或组件需要同一 DLL 的不同版本时,通常会出现 DLL Hell。 当一个应用程序安装的较新版本的 DLL 与依赖旧版本的另一个应用程序不兼容时,就会出现此问题。 这可能会导致受影响的应用程序出现不可预测的行为、崩溃或错误。
为了减轻 DLL Hell 的影响,.NET 框架引入了一个称为“并行程序集”(SxS) 的概念。 SxS 允许同时安装和运行多个版本的 DLL,而不会发生冲突。 每个应用程序都可以指定它所依赖的DLL的版本,.NET运行时将相应地加载适当的版本。
HRESULT: 0x80131040 异常通常与缺少依赖项或在 .NET 应用程序中加载程序集的问题相关。 当运行时无法找到所需的 DLL 或不同版本的程序集之间存在冲突时,通常会发生这种情况。
我们遇到了使用多个 .NET 框架的情况,每个框架都依赖于不同的 NuGet 包。 为了解决这个问题,我们尝试在所有项目中安装相同版本的软件包。 然而,尽管我们做出了努力,错误仍然存在。 令人惊讶的是,当我们在解决方案中创建一个新项目并实现一个方法(...)时,它运行得完美无缺。 这让我们质疑为什么同样的方法不适用于我们的测试项目。
经过进一步调查,我们发现了名为 bindingRedirect 的东西的存在。 为了解决该问题,我们需要将如下所示的配置片段添加到
app.config/.csproj
文件中:但是,由于我们的解决方案中有大量包,因此需要手动添加每个 bindingRedirect 将是一项艰巨的任务,需要数天才能完成。 幸运的是,Visual Studio 提供了一个选项可以自动执行此过程,从而节省了我们大量的时间和精力。
要自动为您的项目生成绑定重定向,请按照下列步骤操作:
通过启用此选项,将自动为您生成绑定重定向。 构建项目后,生成的绑定重定向将包含在名为
bin\debug\projectname.dll.config
的文件中。打开此文件后,您会发现许多绑定重定向。 这可以方便地概述为您的项目生成的所有重定向。
但是,需要注意的是,如果您的测试项目是一个类
库,“自动生成绑定重定向”复选框将不起作用
预期的。
在这种情况下,您需要在
.csproj
中的true
行下方手动添加以下标记:通过包含此标记,绑定重定向也将为您的类库项目正确生成。
可能有帮助的来源:
pretty late, but I want to share our solution to this problem (this problem still exists in 2023). We are using Visual Studio 2022.
Again, this is the error we were getting:
The problem is called DLL Hell and takes a very long time to solve. I hope my answer can shorten your time on it.
DLL Hell refers to a situation where there are conflicts or compatibility issues with dynamic-link libraries (DLLs). DLLs are files containing code and resources that can be used by multiple programs simultaneously, allowing for code reuse and modular programming.
DLL Hell typically arises when different versions of the same DLL are required by different applications or components on a system. The problem occurs when one application installs a newer version of a DLL that is incompatible with another application that relies on an older version. This can result in unpredictable behavior, crashes, or errors in the affected applications.
To mitigate DLL Hell, the .NET framework introduced a concept called "side-by-side assembly" (SxS). SxS allows multiple versions of DLLs to be installed and run simultaneously without conflicts. Each application can specify the version of the DLL it depends on, and the .NET runtime will load the appropriate version accordingly.
The HRESULT: 0x80131040 exception is commonly associated with missing dependencies or issues with loading assemblies in .NET applications. It often occurs when the runtime is unable to locate a required DLL or when there are conflicts between different versions of assemblies.
We encountered a situation where multiple .NET frameworks were being used, each relying on different NuGet packages. To address the issue, we attempted to install the same version of the packages across all projects. However, despite our efforts, the error persisted. Surprisingly, when we created a new project within the solution and implemented a method(...), it worked flawlessly. This led us to question why the same approach didn't work for our test project.
Upon further investigation, we discovered the existence of something called bindingRedirect. To resolve the problem, we needed to add a configuration snippet like the following to the
app.config/.csproj
file:However, with a multitude of packages in our solution, manually adding each bindingRedirect would have been an arduous task taking days to complete. Fortunately, Visual Studio offers an option that automates this process, saving us significant time and effort.
To automatically generate binding redirects for your project, follow these steps:
By enabling this option, the binding redirects will be generated automatically for you. After building the project, the generated bindingRedirects will be included in a file named
bin\debug\projectname.dll.config
.Once you open this file, you will find numerous binding redirects. This provides a convenient overview of all the redirects generated for your project.
However, it's important to note that if your test project is a class
library, the "Auto-generate binding redirects" checkbox won't work as
expected.
In such cases, you need to manually add the following tag beneath the
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
line into you.csproj
:By including this tag, the binding redirects will be properly generated for your class library project as well.
Sources that may help:
就我而言,我在调试时收到此消息:
原因
在我的项目中,我有 2 个使用 RestSharp 的内部组件,但两个组件都有不同版本的 RestSharp(其中一个组件的版本为
105.2.3.0,另一个版本为
106.2.1.0
)。解决方案
将其中一个组件升级到较新的版本,或将另一个组件降级。 就我而言,从
106.2.1.0
降级到105.2.3.0
比在 NuGet 包管理器中更新组件更安全。 因此两个组件具有相同的版本。重建并顺利运行,没有出现任何问题。
In my case I got this message while debugging:
Cause
In my project I have had 2 internal components using the RestSharp but both component have different version of RestSharp (one with version
105.2.3.0
and the other with version106.2.1.0
).Solution
Either upgrade one of the components to newer or downgrade the other. In my case it was safer for me to downgrade from
106.2.1.0
to105.2.3.0
and than update the component in NuGet package manager. So both components has the same version.Rebuild and it worked with out problems.
当测试环境的某个 DLL 的版本与开发环境不匹配时,通常会发生这种情况。
清理并构建您的解决方案,并将所有 DLL 带到发生错误的环境中以修复它
This usually happens when the version of one of the DLLs of the testing environment does not match the development environment.
Clean and Build your solution and take all your DLLs to the environment where the error is happening that should fix it
只需删除 bin 文件夹,然后项目会再次重新创建,现在就可以正常工作了。
Just delete the bin folder and then then the project recreates all again and it will be working now .
我的问题通过删除所有运行时部分解决
My problems solved by remove all the runtime part
这是程序集之间的不匹配:从程序集引用的 DLL 没有预期的方法签名。
清理解决方案,重建所有内容,然后重试。
另外,如果这是对 GAC 中某些内容的引用,请务必小心; 可能是某个地方指向了错误的版本。 确保(通过每个引用的属性)选择了正确的版本或将特定版本设置为 false。
This is a mismatch between assemblies: a DLL referenced from an assembly doesn't have a method signature that's expected.
Clean the solution, rebuild everything, and try again.
Also, be careful if this is a reference to something that's in the GAC; it could be that something somewhere is pointing to an incorrect version. Make sure (through the Properties of each reference) that the correct version is chosen or that Specific Version is set false.
我最近遇到了这个问题,我在有问题的 dll 上运行了“depends.exe”。 它向我展示了 dll 是在 x86 中编译的,而一些依赖项是在 x64 中编译的。
如果您仍然遇到问题,我建议您使用depends.exe。
I recently had this issue and I ran 'depends.exe' on the dll in question. It showed me that the dll was compiled in x86 while some of the dependencys were compiled in x64.
If you are still having troubles I would recommend using depends.exe.
就我的 wcf 休息服务项目而言,我必须向 web.config 添加一个运行时部分,其中请求的 dll 是:
In my case for a wcf rest services project I had to add a runtime section to the web.config where there the requested dll was: