Could not load file or assembly 'System.ValueTuple'

前端 未结 18 1835
你的背包
你的背包 2020-12-08 18:02

I\'ve got a VS2017 project that compiles to a DLL which is then called by an EXE written by someone else. Both projects target .Net Framework 4.6.2. I rewrote one of my DLL

相关标签:
18条回答
  • 2020-12-08 18:44

    ok this feels completely wrong but I cut

      <dependentAssembly>
        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ffffd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
    

    This out of my web.config for the main application.

    I was really just seeing what happened to see if there was an underlying dependency or something, not expecting it to run. It just carried on working, all the new functions I have added in the last few days still work.

    0 讨论(0)
  • 2020-12-08 18:44

    I faced the same exception when there was a nuget package version mismatch. (In the DLL was 4.3.1 used while in the main program 4.3.0.) I have resolved the issue by upgrading the packages to the same version... Checking and unifying the package versions could hopefully help you as well.

    0 讨论(0)
  • 2020-12-08 18:44

    I had this same issue with an AutoMapper 8.0.0.0 dependency on version 4.5 after upgrading from .NET 4.5.1 to 4.6.1. Reinstalling the automapper nuget package worked for me.

    0 讨论(0)
  • 2020-12-08 18:47

    FWIW, I had this issue on my testing project using Moq. Someone had set the project to .NET 4.7, but I was on 4.6.2. Not wanting to move to 4.7 yet, the solution was to downgrade the version to Moq 4.7.145. The System.ValueTuple v 4.3.1 worked together with it.

    0 讨论(0)
  • 2020-12-08 18:47

    In my solution I found 2 different trouble maker. Either in the App.config or Web.config file:

    1. Version mismatch: The version installed via NuGet did not match the version in the config file. Solution: Change the version manually in the .config file.

    2. Duplicate entries: I found duplicate entries for ValueTuple. In my case one for 4.0.3.0 and another one for 4.5.0. Removing the older entry solved the issue.

    In another case I managed to fix the issue by removing unneeded references and getting rid of the ValueTuple NuGet package altogether.

    0 讨论(0)
  • 2020-12-08 18:48

    Adding on to Robin's answer for just changing the Web.config. I was able to get away with only commenting out the binding redirect tag.

    <dependentAssembly>
        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ffffd51" culture="neutral" />
        <!--<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />-->
    </dependentAssembly>
    

    This got rid of the error for me.

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