[CSHARP-3755] ObjectId serialization to JSON fails with PlatformNotSupportedException (Web Assembly) Created: 21/Jul/21 Updated: 27/Oct/23 Resolved: 13/Aug/21 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 2.13.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Ivari Horm | Assignee: | Dmitry Lukyanov (Inactive) |
| Resolution: | Gone away | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10 using Visual Studio 2019, running application in the IIS Express instance for debugging. |
||
| Issue Links: |
|
||||||||
| Description |
|
When I try to serialize an object that has ObjectId defined as a field, I get the PlatformNotSupportedException as the serializer tries to execute System.Diagnostics.Process which seems to be unsupported in .Net 5:
|
| Comments |
| Comment by Backlog - Core Eng Program Management Team [ 13/Aug/21 ] | ||||
|
There hasn't been any recent activity on this ticket, so we're resolving it. Thanks for reaching out! Please feel free to comment on this if you're able to provide more information. | ||||
| Comment by Dmitry Lukyanov (Inactive) [ 27/Jul/21 ] | ||||
|
Hello ivari@risk.ee , I looked deeper at this platform and found that there is much more that it lacks in functionality besides System.Diagnostics.Process, which means that currently the C# driver does not support the Web Assembly platform. One other example: WASM does not support the Task Parallel Library (TPL), upon which the C# driver heavily relies. At this time we do not have plans to support the Web Assembly platform. | ||||
| Comment by Ivari Horm [ 27/Jul/21 ] | ||||
|
Sorry for the delay, summer time causes hectic schedule. I think there is on crucial bit of information lacking - the project is using net5.0 as Web Assembly (Blazor Wasm). Sorry about that, I forgot to include this in my original report. However, Blazor Wasm code is executed inside a browser, the System.Process API is simply not available in a browser environment. I tried to dig around the Microsoft documentation, but could not find anything that explicitly states that, though it seems more than reasonable. There is an article about the unsupported API-s in a browser environment: https://devblogs.microsoft.com/dotnet/the-future-of-net-standard/#dealing-with-apis-that-are-unsupported-in-blazor-webassembly
| ||||
| Comment by Dmitry Lukyanov (Inactive) [ 26/Jul/21 ] | ||||
|
Hey ivari@risk.ee , as it was mentioned above, it looks like the issue is not related to .net5 itself. Can you please provide a small console application with self-contained reproduction? | ||||
| Comment by Robert Stam [ 23/Jul/21 ] | ||||
|
The following also works in a console application using .NET 5:
but System.Text.Json doesn't really understand our data types and serializes it differently than we would. We serialize an ObjectId to JSON as:
But System.Text.Json serializes an ObjectId to JSON as:
| ||||
| Comment by Robert Stam [ 23/Jul/21 ] | ||||
|
The following test works in a console application using .NET 5:
So the problem is not a general .NET 5 problem. It must have something to do with the IIS environment. | ||||
| Comment by Robert Stam [ 23/Jul/21 ] | ||||
|
I missed that you had provided that information in the Environment field: "Windows 10 using Visual Studio 2019, running application in the IIS Express instance for debugging."
| ||||
| Comment by Robert Stam [ 23/Jul/21 ] | ||||
|
Thank you for reporting this issue. It's somewhat surprising since the documentation for GetCurrentProcess says it is support by .NET 5. Can you let us know what platform you were running on when you got this exception (Windows, Linux, OS X?). |