SvcUtil and 'System.Xml.Linq.XElement' cannot be converted to 'System.Xml.XmlElement' compiler error

Tag: error-handling , svcutil.exe Author: fzg00000 Date: 2010-10-03

I always recieve the above error when I generate a proxy class for my service using SvcUtil. The service is exposing a property that is of System.Xml.Linq.XElement type. The SvcUtil generates a System.Xml.XmlElement type property unfortunately. On the other hand if I'm using Add Reference in VS to generate the proxy class, everything's ok. I tried the latest 4.0 version of SvcUtil from the NETFX 4.0 Tools folder, but still with no luck.

Some additional information we found:…
You should not be exposing a .net specific type like this in a datacontract. Why not generate a strongly typed class for the xml structure or just expose a string?
Did you ever figure this out. I am also running into this with a service passing back a Drawing object.

Other Answer1

In case anyone is still looking, like I was, the answer is here:

Yaron Naveh suggests adding a /reference argument to SvcUtil.exe.

svcutil /reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" http://localhost...