-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.ValueTuple - compatibility issue between net 4.8 and net standard 2.0 #84618
Comments
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsDescriptionThere's a specific scenario where in my opinion incorrect assembly is loaded. Basically mix of GAC, nuget package, binding redirect, net 4.8 and net standard 2.0 projects results in: Unhandled Exception: System.TypeLoadException: Method 'get_KeyParametersWithResolver' in type 'ValueTupleIssueDemo.DemoClass' from assembly 'ValueTupleIssueDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. at ValueTupleIssueDemo.Program.Main(String[] args) Reproduction StepsSteps to reproduce the issue
Until now, program should be running just fine.
You'll get: Expected behaviorValueTuple is loaded correctly (from mscorlib or net 4.7 dll with redirect to mscorlib) Actual behaviorSystem.ValueTuple is loaded from GAC and program ends up with Unhandled Exception: System.TypeLoadException: Method 'get_KeyParametersWithResolver' in type 'ValueTupleIssueDemo.DemoClass' from assembly 'ValueTupleIssueDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. at ValueTupleIssueDemo.Program.Main(String[] args) Regression?No response Known Workarounds
Configuration.NET: net 4.8 + net standard 2.0 as target projects Other informationSystem.ValueTuple is from NET 4.7 part of mscorlib, up to that point package was needed. Here partial issue is that Microsoft.Extensions.Configuration.Json has dependency on System.Text.Json
net47 and netstandard1.0 dll for System.ValueTuple have same signature that is token, culture, version etc. Only difference is that net47 version has forwarder Because of the same signature and order of assembly binding, the dll from GAC is loaded. Public repo with reproduced issue (you need to add System.ValueTuple in GAC yourself, see readme) :
|
CC. @ericstj, could you provide input/insight into this scenario? It seems like types are failing to unify here. |
I cannot reproduce this on a clean machine. This part of the repro is invalid:
It sounds to me like someone installed an OOB copy of System.ValueTuple in the GAC and installed a version that didn't match the framework that was installed on the machine. That same package provided a better/correct asset for this machine which should have been used. The assemblies must have the same identity for multi-targeting to work. We rely on asset selection to determine the "correct" one for the framework being targeted. Here the "correct" one is from the Removing the bindingRedirect makes things work because .NETFramework's unification table will force the version to the one inbox. Probably we can report a bug here against MSBuild - it should not be generating bindingRedirects when the assembly is part of the framework. It should recognize that the a newer version is in the framework and not emit a bindingRedirect nor allow an app-local copy. FWIW the |
@PranavSenthilnathan For this issue, if it can still be reproduced using the VS-installed MSBuild as @ericstj described, please file an issue against dotnet/msbuild to capture the scenario with an accurate title and a minimal repro if feasible. |
I can't repro this issue. When I follow the steps and build, the generated binding redirects in the output do not contain |
This issue has been marked |
This issue has been automatically marked |
This issue will now be closed since it had been marked |
Description
There's a specific scenario where in my opinion incorrect assembly is loaded.
Basically mix of GAC, nuget package, binding redirect, net 4.8 and net standard 2.0 projects results in:
Unhandled Exception: System.TypeLoadException: Method 'get_KeyParametersWithResolver' in type 'ValueTupleIssueDemo.DemoClass' from assembly 'ValueTupleIssueDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. at ValueTupleIssueDemo.Program.Main(String[] args)
Reproduction Steps
Steps to reproduce the issue
(can be taken from https://www.nuget.org/packages/System.ValueTuple/4.5.0)
Until now, program should be running just fine.
You'll get:
Unhandled Exception: System.TypeLoadException: Method 'get_KeyParametersWithResolver' in type 'ValueTupleIssueDemo.DemoClass' from assembly 'ValueTupleIssueDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at ValueTupleIssueDemo.Program.Main(String[] args)
Expected behavior
ValueTuple is loaded correctly (from mscorlib or net 4.7 dll with redirect to mscorlib)
Actual behavior
System.ValueTuple is loaded from GAC and program ends up with
Unhandled Exception: System.TypeLoadException: Method 'get_KeyParametersWithResolver' in type 'ValueTupleIssueDemo.DemoClass' from assembly 'ValueTupleIssueDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. at ValueTupleIssueDemo.Program.Main(String[] args)
Regression?
No response
Known Workarounds
Configuration
.NET: net 4.8 + net standard 2.0 as target projects
OS: Tried with Windows 10 21H2 and Windows Server 2019 1809, also Windows Server 2016 all with .net framework 4.8 installed.
Other information
System.ValueTuple is from NET 4.7 part of mscorlib, up to that point package was needed. Here partial issue is that Microsoft.Extensions.Configuration.Json has dependency on System.Text.Json
which then refers to System.ValueTuple, assembly redirection is then generated automatically
net47 and netstandard1.0 dll for System.ValueTuple have same signature that is token, culture, version etc. Only difference is that net47 version has forwarder
to mscorlib, while netstandard1.0 one has implementation of ValueTuple in it.
Because of the same signature and order of assembly binding, the dll from GAC is loaded.
IMPORTANT : but that is ONLY IN CASE where we implement class from net standard 2.0, without it the mscorlib is used directly.
Public repo with reproduced issue (you need to add System.ValueTuple in GAC yourself, see readme) :
https://github.com/martin-stepanek-swi/SystemValueTupleIssue
The text was updated successfully, but these errors were encountered: