A fairly complex object RequestList defined in a WCF Service Reference is also an input parameter for a method in the same Service Reference. An XML is already generated client-side, so all we need to do is XmlSerialize the object, then deserialize the client-side xml. An exception is being thrown when trying to create a new XmlSerializer with the given type.
XmlSerializer serializer = new XmlSerializer(typeof(RequestList));
throws an InvalidOperationException:
Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'ServiceReference.Parameter[]'
to 'ServiceReference.Parameter'
error CS0029: Cannot implicitly convert type 'ServiceReference.Parameter'
to'ServiceReference.Paramter[]'
Shouldn’t arrays be easily serializable? Why is this error being thrown and how can I fix it?
I found what the problem was. Apparently there is a bug of some sort. In the definition of the
RequestListclass, there was a parameter with a double arrayParameter[][]. Apparently that causes issues. The fix is to make it a single array:Parameter[]. Once I did this, it worked perfectly.