Open alexbocharov opened 1 year ago
at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions, Type) + 0x2d
at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions) + 0x2b
at Microsoft.AspNetCore.Builder.DaprEndpointRouteBuilderExtensions.<>c__DisplayClass2_0.<<CreateSubscribeEndPoint>b__0>d.MoveNext() + 0x346
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xbe
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.<Invoke>d__13.MoveNext() + 0xd6
I'm use Dapr.AspNetCore 1.11.0-rc01
@adamreed90 Problem Subscription
. This class is internal on Dapr.
Did you try creating a serializer for it as shown in the 2nd link?
If you're using the .NET 8 Minimal Api with Native AoT Project Example, you need to add the SerializerContext to the TypeInfoResolverChain for Dapr.
Example:
var dapr = app.Services.GetService(typeof(DaprClient)) as DaprClient;
dapr.JsonSerializerOptions.TypeInfoResolverChain.Clear();
dapr.JsonSerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
@adamreed90 at least for me this is not working for dapr workflows. I still get the error mentioned above.
"properties": {
"dapr.workflow.custom_status": "",
"dapr.workflow.failure.error_message": "Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property.",
"dapr.workflow.failure.error_type": "System.InvalidOperationException",
"dapr.workflow.input": ""
}
That's my app right now.
var builder = Host.CreateDefaultBuilder(args).ConfigureServices(services =>
{
services.ConfigureHttpJsonOptions(o =>
{
o.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
services.AddDaprClient(o =>
{
var op = new JsonSerializerOptions();
op.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
o.UseJsonSerializationOptions(op);
});
services.AddDaprWorkflow(options =>
{
options.RegisterWorkflow<GetWeatherAndMood>();
});
});
// Start the app - this is the point where we connect to the Dapr sidecar
using var host = builder.Build();
host.Run();
[JsonSerializable(typeof(IEnumerable<int>))]
[JsonSerializable(typeof(string))]
[JsonSerializable(typeof(IEnumerable<WorkflowResult>))]
internal partial class AppJsonSerializerContext : JsonSerializerContext
{
}
Current version sdk isn't compatible compiles to Native AOT.