开发者

Which types cannot be used for WCF?

开发者 https://www.devze.com 2022-12-24 14:04 出处:网络
I know for a matter of fact that Type cannot be used when passing in to开发者_如何学编程 a WCF service. Does anyone have a complete list?I\'m not sure anyone bothered compiling a list, and i\'m not su

I know for a matter of fact that Type cannot be used when passing in to开发者_如何学编程 a WCF service. Does anyone have a complete list?


I'm not sure anyone bothered compiling a list, and i'm not sure there is any use in compiling one. Instead, there are requirements that a type must meet in order to be used in WCF contracts. Mainly, it has to be serializable.

I think it is the programmer's responsibility to verify that the types used in contracts are all serializable, and to make sure all custom types are serializing and deserializing properly.


Anything that you want to use in a WCF service needs to be serializable first, and secondly, it needs to be able to be expressed using XML schema. Also, WCF is interoprable by nature, so anything that's too specific to .NET (like exceptions, the .NET Type and so forth) should be avoided.

Anything non-serializable is out from the get go, and anything that cannot be expressed in XML schema can't be used either. This includes interfaces - you can only use concrete classes - and it also exludes generic types, since XML schema doesn't know how to handle generic types.

You're quite okay as long as you stick to the basic types (int, string, datetime etc.) and anything that is directly composed from those types.


Anything not marked Serializable, for starters.

0

精彩评论

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

关注公众号