I have just added Automapper to my asp.net application (.net Framework 4.7), to see hopefully being able to replace some of the tedious manual mapping I always need to do.
I am now having a lot of problems with System.ValueTuple versions. I Notice I have a nuget package for System.ValueTuple v4.5.0
. If I look into my solutions packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
I see this as version 4.6.26515.06. If I look into one of the projects I have this nuget package (the one that I added Automapper to), However, when I look in my bin
folder after a build I have version 4.6.25514.4
, ie and older version to what the nuget package has
When I build the app on the build machine picks up 4.6011.3
. Yet another version!!!
I cannot uninstall the nuget package as it says that Automapper has a dependency on it.
When a user ran the application, they go the yellow screen of death, with
Could not load file or assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Does anyone know how to sort out this System.ValueTuple, and know why I seem to be getting random versions of it all over the place?
Thanks in advance!
[EDIT1]
Following @Lucian suggestion, I ran the Fusion tool on both my dev machine, and the other machine where it does not work.
I noticed, on my machine the ValueTuple DLL being found in my bin claimed to be version 4.0.2.0
, and not what the file version was.
So I added...
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="4.0.3.0" newVersion="4.0.2.0" />
</dependentAssembly>
Previously, on my dev machine if I added any of these bindingRedirect
I would also get the error, but now, with the above it worked.
However, it did not on the other production (internal test) machine. From that machine I have the following output (once I finally got Fusion to work) ...
*** Assembly Binder Log Entry (20/11/2018 @ 9:16:49 AM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.ValueTuple
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.ValueTuple | Domain ID: 6
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/MyApp/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\MyApp\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: AppName = ab2266c7
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: A partially-specified assembly bind succeeded from the application directory. Need to re-apply policy.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.3.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: The post-policy assembly reference requires probing again.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
*** Assembly Binder Log Entry (20/11/2018 @ 9:16:49 AM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.ValueTuple
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.ValueTuple | Domain ID: 6
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/MyApp/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\MyApp\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp\0718df87
LOG: AppName = ab2266c7
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: A partially-specified assembly bind succeeded from the application directory. Need to re-apply policy.
LOG: Using application configuration file: C:\inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.3.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: The post-policy assembly reference requires probing again.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp/0718df87/ab2266c7/System.ValueTuple/System.ValueTuple.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MyApp/bin/System.ValueTuple.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MyApp\bin\System.ValueTuple.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I can see the line Redirect found in application configuration file: 4.0.3.0 redirected to 4.0.2.0.
which it gets from the web.config
, and 4.0.2.0
is what should be in the bin folder. This is also the version that shows up in Dotpeek..
For some reason, it then seems to try and get this DLL from C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyApp
, and it seems to end up with Assembly Name is: System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
and then it fails reports..
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: The assembly reference did not match the assembly definition found.
If I remove this bindingRedirect
, it then reports looking for version 0.0.0.0
. I have no idea what is going on here. The version we are trying to remap to, i.e. 4.0.2.0
, is in the bin folder!
I also deleted the folder C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\MyApp
, but this made no difference.
Any other ideas would be greatly appreciated.
User contributions licensed under CC BY-SA 3.0