Error CS0029: Cannot implicitly convert type Using WSDL Tool
Error CS0029: Cannot implicitly convert type Using WSDL Tool
Today I was
asked by one
of developers
I work with to
check an error
he got after he
generated a proxy class with the wsdl.exe tool from a third party
wsdl he got. The error was generated in runtime when he tried to use
the generated class and it was something like:
Unable to generate a temporary class (result=1).
error CS0029: Cannot implicitly convert type 'A' to 'A[]'
After searching in the internet I found that there is a known bug
where the xsd/wsdl generators don’t produce the correct proxy
class. The problem was that the generated class was produced with
a method call that return a jagged array ([][]) instead of a simple array
of type A ([]). In runtime the serialization of an array doesn’t
produce a jagged array and also the opposite and therefore it generate
the exception only in runtime.
How to fix the Problem?
After generating the C# proxy class from the given wsdl check that
the generated class is correct and if not manually fix all the
problems. The fix for our problem was to remove one of the two []
from the jagged array that was generated.
I hope it will help you if you stumble on this error in the future.