Skip to content
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

[Enhancement] when serializing/deserializing a netstandard lib used in .net framework/ net core #2965

Open
mike7ang1rdz opened this issue Jun 27, 2024 · 0 comments

Comments

@mike7ang1rdz
Copy link

When serializing objects in .NET Framework using Newtonsoft JSON, the serializer includes the assembly name in the type name, which is mscorlib for .NET Framework. However, when deserializing in .NET Core, the expected assembly name is System.Private.CoreLib, not mscorlib. This discrepancy causes a TypeNameHandling bug where the deserializer cannot find the type because it’s looking in the wrong assembly. This issue arises because .NET Core and .NET Framework have different core libraries, leading to different type names.

Source/destination types

// Put the types you are serializing or deserializing here

Source/destination JSON

{
"$type": "System.Object, mscorlib",
"Property1": "Value1",
"Property2": 123
}

Expected behavior

it should use TypeForwardedFrom attribute to handle this problem automatically without having to use jsonserializesettings

Actual behavior

throws exception because the assembly wasn't found.

Steps to reproduce

Deserialize the json in net.core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant