dotnet / dotnet/wcf

.Net client generate DataContract cache overflow exception when return type is nullable ValueTuple

Open
#5,833 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.8k
Forks
576
Avg merge
6d 9h
Merged PRs (30d)
2

Description

**Bug description**

Conditions for causing an error:
- When binding is NetTcp. _(not 100% sure that only then)_
- The interface call return type is nullable valuetuple and has return value.
e.g:
`public (double value, string textValue)? TestCall()`

When return value is (12, "SomeText doesn't matter") then:

- With .NET Framework 4.8.1: Works without errors
- With .NET (tested with 6-8): Throws exception.

The exception:
`System.ServiceModel.Dispatcher.NetDispatcherFaultException: 'The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://Microsoft.Samples.NetTcp:ValueTupleTestResult. The InnerException message was 'An internal error has occurred. DataContract cache overflow.'. Please see InnerException for more details.'`

**To Reproduce**

Call wcf service with .net client nullable valuetuple method.

1. I attached a sample project. [Sample.zip](https://github.com/user-attachments/files/22213104/Sample.zip) _(Don't forget change the target to .net)_
2. The full callstack:
`
System.ServiceModel.Primitives.dll!System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(System.Xml.XmlDictionaryReader reader, System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo part, bool isRequest)
System.ServiceModel.Primitives.dll!System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameter(System.Xml.XmlDictionaryReader reader, System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo part, bool isRequest)
System.ServiceModel.Primitives.dll!System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(System.Xml.XmlDictionaryReader reader, System.ServiceModel.Channels.MessageVersion version, string action, System.ServiceModel.Description.MessageDescription messageDescription, object[] parameters, bool isRequest)
System.ServiceModel.Primitives.dll!System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(System.ServiceModel.Channels.Message message, object[] parameters, bool isRequest)
System.ServiceModel.Primitives.dll!System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(System.ServiceModel.Channels.Message message, object[] parameters)
System.ServiceModel.Primitives.dll!System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ref System.ServiceModel.Dispatcher.ProxyRpc rpc)
System.ServiceModel.Primitives.dll!System.ServiceModel.Channels.ServiceChannel.HandleReply(System.ServiceModel.Dispatcher.ProxyOperationRuntime operation, ref System.ServiceModel.Dispatcher.ProxyRpc rpc)
System.ServiceModel.Primitives.dll!System.ServiceModel.Channels.ServiceChannel.Call(string action, bool oneway, System.ServiceModel.Dispatcher.ProxyOperationRuntime operation, object[] ins, object[] outs, System.TimeSpan timeout)
System.ServiceModel.Primitives.dll!System.ServiceModel.Channels.ServiceChannel.Call(string action, bool oneway, System.ServiceModel.Dispatcher.ProxyOperationRuntime operation, object[] ins, object[] outs)
System.ServiceModel.Primitives.dll!System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(System.ServiceModel.Channels.MethodCall methodCall, System.ServiceModel.Dispatcher.ProxyOperationRuntime operation)
System.ServiceModel.Primitives.dll!System.ServiceModel.Channels.ServiceChannelProxy.Invoke(System.Reflection.MethodInfo targetMethod, object[] args)
ProxyBuilder!generatedProxy_1.ValueTupleTest(double value, double value)
client.dll!Microsoft.Samples.NetTcp.CalculatorClient.ValueTupleTest(double n1, double n2) Line 134
at D:\source\client\Connected Services\Microsoft.Samples.NetTcp\Reference.cs(134)
client.dll!Microsoft.Samples.NetTcp.Client.Main() Line 41
at D:\source\client\client.cs(41)
`

**Expected behavior**
It should work the same way as in the .net framework.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.