You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Client/Server setup as comes with the template project. I'm using Remoting to communicate between Client/Server. The types I have are mutually recursive as such:
type A = { Bs: B seq } and B = { As = A seq }
I have a DataService defined that implements the IRemoteService interface and a "FakeDataService" that inherits from RemoteHandler.
The goal is to send back fake data (dummy data, but implemented properly) from the Server to the Client via the DataService interface.
The error is given as such:
fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HMP9CBTKP4T3", Request id "0HMP9CBTKP4T3:00000027": An unhandled exception was thrown by the application. System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.
What I've attempted includes using ReferenceHandler.Preserve. I used the following function to provide customized JsonSerializerOptions in both Client/Server Startup.fs:
let serializerOptions = fun (options: JsonSerializerOptions) -> options.ReferenceHandler <- ReferenceHandler.Preserve JsonFSharpOptions.Default().AddToJsonSerializerOptions(options)
It would be ideal if we could choose to use a different Json library, if possible, instead of only having System.Text.Json some other libraries that handle FSharp Serialization will succeed with cyclical references.
Please let me know if there's any more info I can provide. I'll also be playing with the source code to see if I can get a fix for this in place.
The text was updated successfully, but these errors were encountered:
I have a Client/Server setup as comes with the template project. I'm using Remoting to communicate between Client/Server. The types I have are mutually recursive as such:
type A = { Bs: B seq } and B = { As = A seq }
I have a DataService defined that implements the IRemoteService interface and a "FakeDataService" that inherits from RemoteHandler.
The goal is to send back fake data (dummy data, but implemented properly) from the Server to the Client via the DataService interface.
The error is given as such:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMP9CBTKP4T3", Request id "0HMP9CBTKP4T3:00000027": An unhandled exception was thrown by the application.
System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.
What I've attempted includes using ReferenceHandler.Preserve. I used the following function to provide customized JsonSerializerOptions in both Client/Server Startup.fs:
let serializerOptions = fun (options: JsonSerializerOptions) ->
options.ReferenceHandler <- ReferenceHandler.Preserve
JsonFSharpOptions.Default().AddToJsonSerializerOptions(options)
from Client/Startup.fs:
builder.Services.AddRemoting(builder.HostEnvironment, serializerOptions) |> ignore
from Server/Startup.fs:
services.AddRemoting<FakeDataService.DatabaseAccess>(Client.serializerOptions)
It would be ideal if we could choose to use a different Json library, if possible, instead of only having
System.Text.Json
some other libraries that handle FSharp Serialization will succeed with cyclical references.Please let me know if there's any more info I can provide. I'll also be playing with the source code to see if I can get a fix for this in place.
The text was updated successfully, but these errors were encountered: