开发者

MyType<T> DataContract is in the Silverlight client MyTypeOfT

i have a WCF service with a Property<T> DataContract (with KnownType, et cetera...), but in the Silverlight client I have just PropertyOfint开发者_运维问答, PropertyOfstring, ... types, but I need in Silverlight also a generic type. How?


The soap standard doesn't support the concept of generics so it is not supported directly in WCF. However, you can achieve this support if you control both the client and the WCF service by sharing the ServiceContract DLL between the client and the service. Make sure that this is really what you want since it is not a recommended SOA best practice.

Here is an article that describes how this approach works. By sharing the ServiceContract (not the service implementation DLL) and using the WCF ChannelFactory class you do not need to generate a proxy class since the ChannelFactory class will do this dynamically for you. The ServiceContract assembly will also need to contain all the referenced DataMember marked classes which is the main flaw of this approach because any logic they contain will also be shared. As long as the DataMember classes are just data transfer objects (DTO) then you're not bending the SOA tenents entirely out of shape. The article also explains how to do this with the WCF ClientBase class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜