Skip to content

[Regression] InvalidCastException inside HttpContentHeaders.ContentType #55896

@JamesNK

Description

@JamesNK

I'm trying out .NET 6 with Grpc.Net.Client and I noticed an error when accessing the HttpContentHeaders.ContentType property:

Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Net.Http.Headers.MediaTypeHeaderValue'.

The test is using HTTP/2 and successfully passes in .NET 5. This is a .NET 6 regression.

Exception detail (note that the original exception was wrapped in an RpcException)

    Grpc.Core.RpcException : Status(StatusCode="Internal", Detail="Error starting gRPC call. InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Net.Http.Headers.MediaTypeHeaderValue'.", DebugException="System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Net.Http.Headers.MediaTypeHeaderValue'.
   at System.Net.Http.Headers.HttpContentHeaders.get_ContentType() in System.Net.Http.dll:token 0x6000a27+0x0
   at Grpc.Net.Client.Internal.GrpcCall.ValidateHeaders(HttpResponseMessage httpResponse, Metadata& trailers) in C:\Development\Source\grpc-dotnet\src\Grpc.Net.Client\Internal\GrpcCall.NonGeneric.cs:line 136
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout) in C:\Development\Source\grpc-dotnet\src\Grpc.Net.Client\Internal\GrpcCall.cs:line 461")
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.6.21328.10
 Commit:    2630e4ccfe

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions