Incorrect generated client, two-dimensional array generated in place of list (WCF Connected Services)
See original GitHub issueHacked WSDL: https://gist.github.com/Ravenheart/dc92c2023d3536798aca3e721f5a85ae
In relation to https://github.com/dotnet/wcf/issues/1269 I’ve had some help from the company that made the service and they created a special version that doesn’t have endless recursion possible. Now this new version is added successfully to a sample project BUT the actual generated code throws a runtime exception.
System.AggregateException: One or more errors occurred. (System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e is not assignable from System.String[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.) ---> System.InvalidOperationException: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e is not assignable from System.String[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at TestConsoleNETCore.Program.Main(String[] args) in D:\DEV\TestConsoleNETCore\src\TestConsoleNETCore\Program.cs:line 17
---> (Inner Exception #0) System.InvalidOperationException: System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e is not assignable from System.String[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)<---
The error in question is related to complex types that may end up with properties like “public string[][] SomeProperty” and according to some googling around this is also a bug with .NET’s tooling (tested it with wsdl.exe, svcutil.exe and the new connected services util).
Generated client: https://gist.github.com/Ravenheart/b33e79eba6519088731804b11d8bb6bd
Usage:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace TestConsoleNETCore
{
public class Program
{
public static void Main(string[] args)
{
try
{
PISServiceWS.PISWebServiceClient client = new PISServiceWS.PISWebServiceClient();
//exception here
var res = client.vldContractAsync(new PISServiceWS.vldContractIn()
{
Item = "8610166253",
ItemElementName = PISServiceWS.ItemChoiceType9.egn,
issueDate = new DateTime(2016, 6, 6),
issueDateSpecified = true,
practiceNo = "2211131508",
specCode = "01",
uin = "0500000012",
}).Result;
Console.WriteLine(res.vldContractOut.vld);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:29 (9 by maintainers)

Top Related StackOverflow Question
@Ravenheart The generated code for the two dimensional array tr is not correct. In XmlArrayItemAttribute, we need either use typeof(string[]) or add NestingLevel=1. We’ll look at the root cause.
To work around this issue now, you can edit the generated code and make the change yourself as below. [System.Xml.Serialization.XmlArrayAttribute(Order=1)] [System.Xml.Serialization.XmlArrayItemAttribute(“td”, typeof(string), IsNullable=false)] public string[][] tr {}
Either use [System.Xml.Serialization.XmlArrayItemAttribute(“td”, typeof(string[]), IsNullable=false)] Or [System.Xml.Serialization.XmlArrayItemAttribute(“td”, typeof(string), IsNullable=false, NestingLevel=1)]
@eng-marani its been there since the early 2000s 😃