-
Notifications
You must be signed in to change notification settings - Fork 67
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Starting ASP.NET6 Application with NLog EcsLayout where it fails to serialize object of type Microsoft.AspNetCore.Routing.RouteEndpoint coming from this log-message from Microsoft ASP.NET (Logger-Category = "Microsoft.AspNetCore.Routing.EndpointMiddleware"):
Executing endpoint '{EndpointName}'
Exception Details (Looks like it fails with a nested-value of type Microsoft.AspNetCore.Routing.Patterns.RoutePattern):
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=System.Text.Json
StackTrace:
> System.Text.Json.dll!System.Text.Json.Serialization.JsonDictionaryConverter<System.Collections.Generic.IReadOnlyDictionary<string, object>, string, object>.OnTryWrite(System.Text.Json.Utf8JsonWriter writer, System.Collections.Generic.IReadOnlyDictionary<string, object> dictionary, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<System.Collections.Generic.IReadOnlyDictionary<string, object>>.TryWrite(System.Text.Json.Utf8JsonWriter writer, System.Collections.Generic.IReadOnlyDictionary<string, object> value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.Metadata.JsonPropertyInfo<System.Collections.Generic.IReadOnlyDictionary<string, object>>.GetMemberAndWriteJson(object obj, ref System.Text.Json.WriteStack state, System.Text.Json.Utf8JsonWriter writer) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.Converters.ObjectDefaultConverter<Microsoft.AspNetCore.Routing.Patterns.RoutePattern>.OnTryWrite(System.Text.Json.Utf8JsonWriter writer, Microsoft.AspNetCore.Routing.Patterns.RoutePattern value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<Microsoft.AspNetCore.Routing.Patterns.RoutePattern>.TryWrite(System.Text.Json.Utf8JsonWriter writer, Microsoft.AspNetCore.Routing.Patterns.RoutePattern value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.Metadata.JsonPropertyInfo<Microsoft.AspNetCore.Routing.Patterns.RoutePattern>.GetMemberAndWriteJson(object obj, ref System.Text.Json.WriteStack state, System.Text.Json.Utf8JsonWriter writer) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.Converters.ObjectDefaultConverter<Microsoft.AspNetCore.Routing.RouteEndpoint>.OnTryWrite(System.Text.Json.Utf8JsonWriter writer, Microsoft.AspNetCore.Routing.RouteEndpoint value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<Microsoft.AspNetCore.Routing.RouteEndpoint>.TryWrite(System.Text.Json.Utf8JsonWriter writer, Microsoft.AspNetCore.Routing.RouteEndpoint value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<System.__Canon>.WriteCore(System.Text.Json.Utf8JsonWriter writer, System.__Canon value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<Microsoft.AspNetCore.Routing.RouteEndpoint>.WriteCoreAsObject(System.Text.Json.Utf8JsonWriter writer, object value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.JsonSerializer.WriteUsingSerializer<object>(System.Text.Json.Utf8JsonWriter writer, object value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo) Unknown
System.Text.Json.dll!System.Text.Json.JsonSerializer.Serialize(System.Text.Json.Utf8JsonWriter writer, object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options) Unknown
Elastic.CommonSchema.dll!Elastic.CommonSchema.Serialization.MetaDataDictionaryConverter.Write(System.Text.Json.Utf8JsonWriter writer, System.Collections.Generic.IDictionary<string, object> value, System.Text.Json.JsonSerializerOptions options) Line 69 C#
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<System.Collections.Generic.IDictionary<string, object>>.TryWrite(System.Text.Json.Utf8JsonWriter writer, System.Collections.Generic.IDictionary<string, object> value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<System.__Canon>.WriteCore(System.Text.Json.Utf8JsonWriter writer, System.__Canon value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.Serialization.JsonConverter<System.Collections.Generic.IDictionary<string, object>>.WriteCoreAsObject(System.Text.Json.Utf8JsonWriter writer, object value, System.Text.Json.JsonSerializerOptions options, ref System.Text.Json.WriteStack state) Unknown
System.Text.Json.dll!System.Text.Json.JsonSerializer.WriteUsingSerializer<object>(System.Text.Json.Utf8JsonWriter writer, object value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo) Unknown
System.Text.Json.dll!System.Text.Json.JsonSerializer.Serialize(System.Text.Json.Utf8JsonWriter writer, object value, System.Type inputType, System.Text.Json.JsonSerializerOptions options) Unknown
public override void Write(Utf8JsonWriter writer, IDictionary<string, object> value, JsonSerializerOptions options)
{
writer.WriteStartObject();
foreach (var kvp in value)
{
var propertyName = SnakeCaseJsonNamingPolicy.ToSnakeCase(kvp.Key);
writer.WritePropertyName(propertyName);
if (kvp.Value == null)
writer.WriteNullValue();
else
{
var inputType = kvp.Value.GetType();
JsonSerializer.Serialize(writer, kvp.Value, inputType, options); // <-- throws
}
}
writer.WriteEndObject();
}| Name | Value | Type | |
|---|---|---|---|
| inputType.ToString() | "Microsoft.AspNetCore.Routing.RouteEndpoint" | string |
| Name | Value | Type | |
|---|---|---|---|
| ◢ | kvp.Value | {ASP.NetCore6_NLog_Web_Example.Controllers.HomeController.Index (ASP.NetCore6_NLog_Web_Example)} | object {Microsoft.AspNetCore.Routing.RouteEndpoint} |
| DisplayName | "ASP.NetCore6_NLog_Web_Example.Controllers.HomeController.Index (ASP.NetCore6_NLog_Web_Example)" | string | |
| ◢ Metadata | {Microsoft.AspNetCore.Http.EndpointMetadataCollection} | Microsoft.AspNetCore.Http.EndpointMetadataCollection | |
| Count | 10 | int | |
| ◢ Results View | Expanding the Results View will enumerate the IEnumerable | ||
| ▶ [0] | {System.Runtime.CompilerServices.NullableContextAttribute} | object {System.Runtime.CompilerServices.NullableContextAttribute} | |
| ▶ [1] | {System.Runtime.CompilerServices.NullableAttribute} | object {System.Runtime.CompilerServices.NullableAttribute} | |
| ▶ [2] | {Microsoft.AspNetCore.Mvc.ControllerAttribute} | object {Microsoft.AspNetCore.Mvc.ControllerAttribute} | |
| ▶ [3] | "ASP.NetCore6_NLog_Web_Example.Controllers.HomeController.Index (ASP.NetCore6_NLog_Web_Example)" | object {Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor} | |
| ▶ [4] | {Microsoft.AspNetCore.Routing.DataTokensMetadata} | object {Microsoft.AspNetCore.Routing.DataTokensMetadata} | |
| ▶ [5] | Name: default | object {Microsoft.AspNetCore.Routing.RouteNameMetadata} | |
| ▶ [6] | {Microsoft.AspNetCore.Mvc.Filters.ControllerActionFilter} | object {Microsoft.AspNetCore.Mvc.Filters.ControllerActionFilter} | |
| ▶ [7] | {Microsoft.AspNetCore.Mvc.ViewFeatures.SaveTempDataAttribute} | object {Microsoft.AspNetCore.Mvc.ViewFeatures.SaveTempDataAttribute} | |
| ▶ [8] | {Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter} | object {Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilter} | |
| ▶ [9] | {Microsoft.AspNetCore.Routing.SuppressLinkGenerationMetadata} | object {Microsoft.AspNetCore.Routing.SuppressLinkGenerationMetadata} | |
| Order | 1 | int | |
| ◢ RequestDelegate | {Method = {System.Threading.Tasks.Task b__0(Microsoft.AspNetCore.Http.HttpContext)}} | Microsoft.AspNetCore.Http.RequestDelegate | |
| ▶ Method | {System.Threading.Tasks.Task b__0(Microsoft.AspNetCore.Http.HttpContext)} | System.Reflection.MethodInfo {System.Reflection.RuntimeMethodInfo} | |
| ▶ Target | {Microsoft.AspNetCore.Mvc.Routing.ControllerRequestDelegateFactory.<>c__DisplayClass10_0} | object {Microsoft.AspNetCore.Mvc.Routing.ControllerRequestDelegateFactory.<>c__DisplayClass10_0} | |
| ▶ Non-Public members | |||
| ◢ RoutePattern | "{controller=Home}/{action=Index}/{id?}" | Microsoft.AspNetCore.Routing.Patterns.RoutePattern | |
| ▶ Defaults | Count = 2 | System.Collections.Generic.IReadOnlyDictionary<string, object> {System.Collections.Generic.Dictionary<string, object>} | |
| InboundPrecedence | 1.13 | decimal | |
| OutboundPrecedence | 3.33 | decimal | |
| ▶ ParameterPolicies | Count = 0 | System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Routing.Patterns.RoutePatternParameterPolicyReference>> {System.Collections.ObjectModel.ReadOnlyDictionary<string, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Routing.Patterns.RoutePatternParameterPolicyReference>>} | |
| ▶ Parameters | Count = 3 | System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Routing.Patterns.RoutePatternParameterPart> {System.Collections.Generic.List<Microsoft.AspNetCore.Routing.Patterns.RoutePatternParameterPart>} | |
| ▶ PathSegments | {Microsoft.AspNetCore.Routing.Patterns.RoutePatternPathSegment[3]} | System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Routing.Patterns.RoutePatternPathSegment> {Microsoft.AspNetCore.Routing.Patterns.RoutePatternPathSegment[]} | |
| RawText | "{controller=Home}/{action=Index}/{id?}" | string | |
| ▶ RequiredValues | {Microsoft.AspNetCore.Routing.RouteValueDictionary} | System.Collections.Generic.IReadOnlyDictionary<string, object> {Microsoft.AspNetCore.Routing.RouteValueDictionary} |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working