开发者

Webservice referencing a class with a property of type Icon

in my webservice I'm referencing a dll with a class which holds a property of type Icon开发者_运维百科 (among others of type string and DateTime). When creating a service reference in my UnitTest-project I get the following error.

Error:

ISerializable type with data contract name 'Icon' in namespace 'http://schemas.datacontract.org/2004/07/System.Drawing' cannot be imported. The data contract namespace cannot be customized for ISerializable types and the generated namespace 'KoenHoefman.ExchangeRate.WS.NUnit.QueryService' does not match the required CLR namespace 'System.Drawing'. Check if the required namespace has been mapped to a different data contract namespace and consider mapping it explicitly using the namespaces collection.

I do have access to the source-code of this dll, so it's possible to make some changes, but these changes should be very minimized. The class is marked with the Serializable attribute, which probably gives the previous error. When removing this attribute I got another error that stated that I had to mark the class with the DataContractAttribute and the members with the DataMemberAttribute.

Now to me this seems a big change since this class is rarely used in a webservice (just this time). I haven't tried this yet, but I was wondering if there's another solution to my problem.

Thanks.


My suggestion is that you create another class to carry the data - this class can wrap around problematic class and expose needed properties - you should annotate this class with DataContractAttribute & DataMemberAttribute - it is always a good idea to explicitly mark your service contract.

As far as icon goes, you need to decide if you must transport/expose icon information via web service. If yes then you could expose a property of type byte[] (or base64 encoded string) to transmit the icon data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜