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

前端 未结 30 2061
北恋
北恋 2020-11-22 01:41

I am trying to run some unit tests in a C# Windows Forms application (Visual Studio 2005), and I get the following error:

System.IO.FileLoadException: Co

相关标签:
30条回答
  • 2020-11-22 01:58

    Just deleting contents of your project's bin folder and rebuild the solution solved my problem.

    0 讨论(0)
  • 2020-11-22 01:58

    clean and rebuild the solution might not replace all the dll's from the output directory.

    what i'll suggest is try renaming the folder from "bin" to "oldbin" or "obj" to "oldobj"

    and then try build your silution again.

    incase if you are using any third party dll's those you will need to copy into newly created "bin" or "obj" folder after successful build.

    hope this will work for you.

    0 讨论(0)
  • 2020-11-22 01:58

    In my case the problem was between the chair and the keyboard :-)

    Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies.
    The located assembly's manifest definition does not match the assembly reference.
    (Exception from HRESULT: 0x80131040)
    

    Two or more different assemblies wanted to use a different version of the DotNetOpenAuth library, and that would not be a problem. Furthermore, on my local computer a web.config was automatically updated by NuGet:

    <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
    </dependentAssembly>
    

    Then I realized that I had forgot to copy/deploy the new web.config to the production server. So if you have manual way of deploying web.config, check it is updated. If you have completely different web.config for production server, you have to merge these dependentAssembly section in sync after using NuGet.

    0 讨论(0)
  • 2020-11-22 01:59

    This exact same error is thrown if you try to late bind using reflection, if the assembly you are binding to gets strong-named or has its public-key token changed. The error is the same even though there is not actually any assembly found with the specified public key token.

    You need to add the correct public key token (you can get it using sn -T on the dll) to resolve the error. Hope this helps.

    0 讨论(0)
  • 2020-11-22 02:01

    I am going to blow everyone's mind right now . . .

    Delete all the <assemblyBinding> references from your .config file, and then run this command from the NuGet Package Manager console:

    Get-Project -All | Add-BindingRedirect
    
    0 讨论(0)
  • 2020-11-22 02:02

    I'll let someone benefit from my shear stupidity. I have some dependencies to a completely separate application (let's call this App1). The dll's from that App1 are pulled into my new application (App2). Any time I do updates in APP1, I have to create new dll's and copy them into App2. Well. . .I got tired of copying and pasting between 2 different App1 versions, so I simply added a 'NEW_' prefix to the dll's.

    Well. . . I'm guessing that the build process scans the /bin folder and when it matches something up incorrectly, it barfs with the same error message as noted above. I deleted my "new_" versions and it built just dandy.

    0 讨论(0)
提交回复
热议问题