Failed to load file or assembly "System.ValueTuple"

I have a VS2017 project that compiles into a DLL, which is then called by an EXE written by someone else. Both projects focus on .Net Framework 4.6.2. I rewrote one of my DLL methods to return a tuple, and also imported the related NuGet package. When I compile the project, it includes System.ValueTuple.dll in the output directory, which is then deployed to other machines where my DLL is loaded and the EXE is called. But when the EXE tries to call a method that returns a tuple, it fails:

Unexpected error Failed to load the file or assembly "System.ValueTuple, Version = 4.0.1.0, Culture = neutral, PublicKeyToken = cc7b13ffcd2ddd51" or one of its dependencies. The system cannot find the specified file.

I do not understand why it does not find the file, since it is in the same folder as my DLL. Apparently, MS did not include this assembly in .Net Framework 4.6.2.

Please note that my DLL is registered in Windows using the machine.config file. I assume that if I also add System.ValueTuple.dll to this file, it will work (I have not tried it yet and I'm not sure if this is the best approach, especially the long-term one.) Is there a better way besides waiting 4.6.3 and hoping What does it include this assembly?

+36
source share
10 answers

, System.ValueTuple machine.config ( DLL, ). , DLL, . , MS .NET Framework.

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" />
    <bindingRedirect oldVersion="0.0.0.0-99.99.99.99" newVersion="4.0.1.0" />
    <codeBase version="4.0.1.0" href="e:\exec\System.ValueTuple.dll" />
  </dependentAssembly>
  ...
</assemblyBinding>
</runtime>
+6

. Localhost , . , - .Net Framework 4.6.1 , System.ValueTuple, Nuget 4.5.0.

Nuget System.ValueTuple 4.3.0. , .

, , - .net framework.

+22

, ,

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

web.config .

, , , - , , . , , , .

+13

FWIW, Moq. - .NET 4.7, 4.6.2. 4.7, Moq 4.7.145. System.ValueTuple v 4.3.1 .

+9

, nuget. ( DLL 4.3.1, 4.3.0.) , ... , , .

+8

, .NET Framework 4.7.2 Runtime , . bindingRedirect NuGet.

https://dotnet.microsoft.com/download/dotnet-framework/net472

+3

, 4.6.1, 4.7.2. , , .Net , 4.7.2 , Nuget.

( SQLite AWS EC2)

+1

AutoMapper 8.0.0.0 4.5 .NET 4.5.1 4.6.1. Nuget automapper .

0

, , .Net Framwork 4.7.1.

System.ValueTuple .NET Framework 4.7

0

.Net Framework , : Microsoft.Net.Compilers 2.10. .

0

Source: https://habr.com/ru/post/1672603/


All Articles