DCSIMG
Error CS0029: Cannot implicitly convert type Using WSDL Tool - Gil Fink's Blog

Gil Fink's Blog

Fink about IT

News

Microsoft MVP

My Facebook Profile My Twitter Profile My Linkedin Profile

Locations of visitors to this page

Creative Commons License

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2013 Gil Fink

Hebrew Articles

Index Pages

My OSS Projects

English Articles

Error CS0029: Cannot implicitly convert type Using WSDL Tool

Error CS0029: Cannot implicitly convert type Using WSDL Tool

Today I wasError CS0029: Cannot implicitly convert type Using WSDL Tool
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.

DotNetKicks Image

Comments

Yaron Naveh said:

I've given another analysis of this issue in this post:

webservices20.blogspot.com/.../net-wcf-bug-cannot-convert-type-to.html

Seems like there is another way to fix it which will not break in case of "update service reference".

# February 27, 2010 4:17 PM

Gil Fink said:

Hi Yaron Naveh,

I read your post which includes good explanation.

In my situation it's a third party java service which we can't change it's wsdl.

# February 27, 2010 5:24 PM

Yaron Naveh said:

Hi Gil

You can save the wsdl locally and change it b4 you add reference. This would also break when the wsdl changes but it might be easier to automate.

# February 28, 2010 9:42 AM

Gil Fink said:

Thanks Yaron Naveh.

# February 28, 2010 12:23 PM