-
Notifications
You must be signed in to change notification settings - Fork 5k
Wrong version for System.Text.Json in nuget package? #78754
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
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionThe nuget package System.Text.Json 6.0.7 has these assembly versions I have a A When running the app, the first call into the library fails because it can't find assembly version 6.0.0.0 Reproduction StepsCreate netstandard 2.0 library
create netframework 4.8 console app namespace TextJsonApp
{
public static class Program()
{
var x = new TextJsonLibrary.JsonDto();
}
} Expected behaviorNo error Actual behavior
Regression?I have only used the 5.0.0 and 6.0.0 versions before and there all assembly versions are the same. Checked some older nuget packages in 5.x and 6.x and all .NetFramework assemblies have different versions. Known WorkaroundsDowngrade the package in the .NetFramework app to 6.0.0 ConfigurationNo response Other informationNo response
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure Issue DetailsDescriptionThe nuget package System.Text.Json 6.0.7 has these assembly versions I have a A When running the app, the first call into the library fails because it can't find assembly version 6.0.0.0 Reproduction StepsCreate netstandard 2.0 library
create netframework 4.8 console app namespace TextJsonApp
{
public static class Program()
{
public static void Main()
{
var x = new TextJsonLibrary.JsonDto();
}
}
} Expected behaviorNo error Actual behavior
Regression?I have only used the 5.0.0 and 6.0.0 versions before and there all assembly versions are the same. Checked some older nuget packages in 5.x and 6.x and all .NetFramework assemblies have different versions. Known WorkaroundsDowngrade the package in the .NetFramework app to 6.0.0 ConfigurationNo response Other informationNo response
|
This should not happen thanks to assembly binding redirects, which should be generated automatically. Indeed, I can't reproduce this after a fresh build, even after forcing the loading of System.Text.Json by changing the code of the app to Though I can reproduce it if I delete the <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.7" newVersion="6.0.0.7" />
</dependentAssembly>
</assemblyBinding> Is the "Auto-generate binding redirects" option enabled in your project? What is the contents of your |
Thank you for your reply and you are correct of course that binding redirect can solve many assembly versioning problems. Didn't think about that and should have given more context than the minimal reproduction. In my environment I don't have access to app.config so binding redirect is not available, i.e. plugins. This of course create various dependency problems which we solve by forcing all our projects to use the same version of dependencies and update them together. This is the first time we ran into a problem where all assemblies use the same version of all dependencies. Now I understand why it isn't a more general problem and probably shouldn't be a bug. The workaround of forcing version 6.0.0 works fine for us. May I ask why only the .NetFramework assemblies have different version numbers? |
On .NET Framework, the loader requires exact version matches. If an assembly binds against 6.0.0.0 but at runtime, only 6.0.0.1 is present, the loader fails without binding redirects. This isn't the case on modern .NET (or Core, if you want to call it that), as the loader automatically rolls forward on patch versions.
.NET Framework assemblies are part of the GAC (Global Assembly Cache). Without updating the package's assembly version, the assembly inside the GAC would win over what's coming via the package. That's basically a caching mechanism. On the other side, we don't want to rev the version of net6.0 System.Text.Json assembly, as it also ships inside the shared framework. If we would change its version, then newer patched shared framework installation (that ships as part of the .NET SDK) would never win over the package asset. |
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsDescriptionThe nuget package System.Text.Json 6.0.7 has these assembly versions I have a A When running the app, the first call into the library fails because it can't find assembly version 6.0.0.0 Reproduction StepsCreate netstandard 2.0 library namespace TextJsonLibrary
{
public class JsonDto
{
[System.Text.Json.Serialization.JsonPropertyName("prop")]
public int Prop {get; set;}
}
} create netframework 4.8 console app namespace TextJsonApp
{
public static class Program()
{
public static void Main()
{
var x = new TextJsonLibrary.JsonDto();
}
}
} Expected behaviorNo error Actual behavior
Regression?I have only used the 5.0.0 and 6.0.0 versions before and there all assembly versions are the same. Checked some older nuget packages in 5.x and 6.x and all .NetFramework assemblies have different versions. Known WorkaroundsDowngrade the package in the .NetFramework app to 6.0.0 which contain a .NetFramework assembly with version 6.0.0.0 ConfigurationNo response Other informationNo response
|
This issue has been marked |
Thank you for your reply. I know the background now and will close the issue. |
Uh oh!
There was an error while loading. Please reload this page.
Description
The nuget package System.Text.Json 6.0.7 has these assembly versions

I have a
NetStandard 2.0
library using System.Text.Json 6.0.7 and therefore has a dependency on assembly version 6.0.0.0A
.NetFramework 4.8
app depends on the.NetStandard 2.0
library and has an indirect dependency on System.Text.Json 6.0.7 and therefore assembly version 6.0.0.7.When running the app, the first call into the library fails because it can't find assembly version 6.0.0.0
Reproduction Steps
Create netstandard 2.0 library
add system.text.json 6.0.7
create netframework 4.8 console app
add library and system.text.json 6.0.7 (or create nuget package from library and add)
Expected behavior
No error
Actual behavior
Regression?
I have only used the 5.0.0 and 6.0.0 versions before and there all assembly versions are the same.
Checked some older nuget packages in 5.x and 6.x and all .NetFramework assemblies have different versions.
Known Workarounds
Downgrade the package in the .NetFramework app to 6.0.0 which contain a .NetFramework assembly with version 6.0.0.0
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: