.net HRESULT:0x80131040:定位的程序集的清单定义与程序集引用不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/93879/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 09:57:01  来源:igfitidea点击:

HRESULT: 0x80131040: The located assembly's manifest definition does not match the assembly reference

.netnunitncover

提问by

The located assembly's manifest definition does not match the assembly reference

定位的程序集的清单定义与程序集引用不匹配

getting this when running nunit through ncover. Any idea?

通过 ncover 运行 nunit 时得到这个。任何的想法?

回答by Jeremy McGee

This is a mismatch between assemblies: a DLL referenced from an assembly doesn't have a method signature that's expected.

这是程序集之间的不匹配:从程序集引用的 DLL 没有预期的方法签名。

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.

另外,如果这是对 GAC 中某些内容的引用,请注意;可能是某处的某些东西指向了不正确的版本。确保(通过每个引用的属性)选择了正确的版本或将特定版本设置为 false。

回答by Kyle

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.

我最近遇到了这个问题,我在有问题的 dll 上运行了“depends.exe”。它告诉我 dll 是在 x86 中编译的,而一些依赖项是在 x64 中编译的。

If you are still having troubles I would recommend using depends.exe.

如果您仍然遇到问题,我建议您使用depends.exe。

回答by fguigui

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:

在我的 wcf 休息服务项目的情况下,我必须向 web.config 添加一个运行时部分,其中请求的 dll 是:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
.
.
.
  <runtime>

回答by kyorilys

My problems solved by remove all the runtime part

通过删除所有运行时部分解决了我的问题

<runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

回答by Mauricio Gracia Gutierrez

This usually happens when the version of one of the DLLs of the testing environment does not match the development environment.

当测试环境的 DLL 之一的版本与开发环境不匹配时,通常会发生这种情况。

Clean and Build your solution and take all your DLLs to the environment where the error is happening that should fix it

清理并构建您的解决方案,并将所有 DLL 带到发生错误的环境中以修复它

回答by H?kan L?fqvist

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.

通过共享文件夹从不同计算机访问项目文件时,我遇到了类似的问题。就我而言,clean + rebuild 没有帮助。必须从输出目录中删除 bin 和 objects 文件夹。

回答by j.j.a.c.k.

Just deleted bin folder and project recreates all and now it is working.

刚刚删除的 bin 文件夹和项目重新创建了所有,现在它正在工作。

回答by maytham-???????

In my case I got this message while debugging:

就我而言,我在调试时收到此消息:

"Error while calling service <ServiceName> Could not load file or assembly 'RestSharp, 
Version=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)"

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.0and the other with version 106.2.1.0).

在我的项目中,我有 2 个使用 RestSharp 的内部组件,但两个组件都有不同版本的 RestSharp(一个带有 version105.2.3.0另一个带有 version 106.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.0to 105.2.3.0and than update the component in NuGet package manager. So both components has the same version.

将其中一个组件升级到更新版本或降级另一个组件。在我的情况下,对我来说,从NuGet 包管理器降级106.2.1.0105.2.3.0更新组件比更新组件更安全。所以这两个组件具有相同的版本。

Rebuild and it worked with out problems.

重建并解决了问题。

回答by sandiejat

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.

就我而言,这是由于 WebGrease 而发生的。我将它更新到最新版本(使用 NuGet),但它与依赖项冲突。我在 web.config 中手动添加了以下代码,它起到了很好的作用。

<dependentAssembly>
    <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>

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.

请注意,我的解决方案仅在错误与 WebGrease 相关时才有效。错误代码将保持不变。此外,您需要相应地更改 oldVersion 和 newVersion 中的版本。

回答by Bj?rn van den Heuvel

In my particular situation, I got this as a result of a CreateObjectdone 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).

在我的特殊情况下,我CreateObject是在 VBScript 中完成的。在我的案例中,原因是驻留在 GAC 中的程序集版本比我编译的版本旧。(为了解决之前的问题,我在 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.

因此,如果您正在使用 COM 可见类,那么在使用 RegASM 注册新程序集之前,请确保从 GAC 中删除旧版本的程序集。