HRESULT: 0x80131040: The located assembly's ma

2019-01-11 05:37发布

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

getting this when running nunit through ncover. Any idea?

18条回答
祖国的老花朵
2楼-- · 2019-01-11 06:26

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.

查看更多
一夜七次
3楼-- · 2019-01-11 06:26

In my case for a wcf rest services project i had to add in the web.config a runtime section where there was the requested dll, then i add :

  <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>
查看更多
太酷不给撩
4楼-- · 2019-01-11 06:27

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.

查看更多
三岁会撩人
5楼-- · 2019-01-11 06:28

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.0 and the other with 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.0 to 105.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.

查看更多
6楼-- · 2019-01-11 06:31

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.

<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.

查看更多
Lonely孤独者°
7楼-- · 2019-01-11 06:31

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:

"Error HRESULT E_FAIL has been returned from a call to a COM component."

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.

查看更多
登录 后发表回答