-
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.Text.Json throw exceptions on UWP in Release Build #29912
Comments
You can get more information in the exception message if you switch your build type to Debug and turn on .NET Native in the Debug configuration: switch the project configuration to Debug, and then in the project properties on the Build tab check the checkbox next to "Compile with .NET Native tool chain". The exception message will have more details after you do that. Reflection-based serializers typically require RD.XML to make them work right out of the box. System.Text.Json wasn't tested on UWP and the experience will be rough. For UWP, it's recommended to use existing serializers that the .NET Native compiler understands such as DataContractJsonSerializer or Netwonsoft.Json. (I should probably point out that the reason why the experience it's going to be more rough for System.Text.Json is because this is a framework assembly and a lot of the things in the .NET Native compiler that try to make reflection experience better don't kick in for framework assemblies - framework assemblies are expected to carry their own RD.XML that describes their dynamic behavior so that the compiler can do aggressive treeshaking on them to reduce their size. We didn't make an investment into RD.XML for System.Text.Json.) |
@MichalStrehovsky
test code: JsonSerializer.ToString(new { test = "abc" }); |
Oh, okay, I actually looked and right now it's impossible to make System.Text.Json work on UWP. The When .NET Native support was deleted in CoreFX in dotnet/corefx#38170, along with it we deleted the logic that injects this attribute into framework assemblies. Next System.Text.Json release probably won't have that and we can try again. |
Only if using .NET Native, right? I think the latest version of UWP should run with the regular .NET Core 2.2 runtime otherwise, where STJ seems to be working OK for me. |
.NET Native is still a requirement to ship UWP apps to the Store. |
@ViktorHofer can you clarify the resolution on all these issues that are getting closed? |
@sharwell you asked that question already on another issue. Please see my response there. This one actually was a mistake and needs to be re-opened. |
Just to bump this with something I discovered today, calls to JasonSerializer.Serialize() were working fine using UWP .NET Native against .NET Core 3.0. After updating to .NET Core 3.1 preview 3, calls to Serialize now fail with metadata exceptions. |
#978 (comment) |
FYI @MattWhilden Relinking to our Windows Community Toolkit Issue here as well. |
Here's the issue I've been using to track this getting resolved. The current design question is around PreserveDependencyAttribute and whether it will be renamed/reused etc. In the mean time we'll need to have rd.xml workarounds. |
I added this to
|
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of the experimental issue cleanup initiative we are currently trialing in a limited number of areas. Please share any feedback you might have in the linked issue. |
It would be useful if we had some official indication of what the status of UWP is and how it fits into the .NET Core ecosystem in order to figure out if this issue even matters in the grand scheme of things. |
Use System.Json.Text in UWP,
The text was updated successfully, but these errors were encountered: