-
Type: Bug
-
Resolution: Gone away
-
Priority: Unknown
-
None
-
Affects Version/s: 2.13.0
-
Component/s: None
-
None
-
Environment:Windows 10 using Visual Studio 2019, running application in the IIS Express instance for debugging.
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:
Unhandled exception rendering component: The type initializer for 'MongoDB.Bson.ObjectId' threw an exception. System.TypeInitializationException: The type initializer for 'MongoDB.Bson.ObjectId' threw an exception. ---> System.PlatformNotSupportedException: System.Diagnostics.Process is not supported on this platform. at System.Diagnostics.Process.GetCurrentProcess() at MongoDB.Bson.ObjectId.GetCurrentProcessId() at MongoDB.Bson.ObjectId.GetPid() at MongoDB.Bson.ObjectId.CalculateRandomValue() at MongoDB.Bson.ObjectId..cctor() --- End of inner exception stack trace --- at System.Text.Json.JsonPropertyInfo`1[[System.Int32, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1[[MongoDB.Bson.ObjectId, MongoDB.Bson, Version=2.13.0.0, Culture=neutral, PublicKeyToken=null]].OnTryWrite(Utf8JsonWriter writer, ObjectId value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.Serialization.JsonConverter`1[[MongoDB.Bson.ObjectId, MongoDB.Bson, Version=2.13.0.0, Culture=neutral, PublicKeyToken=null]].TryWrite(Utf8JsonWriter writer, ObjectId& value, JsonSerializerOptions options, WriteStack& state) at System.Text.Json.JsonPropertyInfo`1[[MongoDB.Bson.ObjectId, MongoDB.Bson, Version=2.13.0.0, Culture=neutral, PublicKeyToken=null]].GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1[[CPM.Auth.Models.User, CPM.Auth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnTryWrite(Utf8JsonWriter writer, User value, JsonSerializerOptions options, WriteStack& state)
- related to
-
CSHARP-4551 Avoid using PID when generating ObjectIds
- Closed