开发者

Passing Object as a parameter to a WCF Service

I have a method AddEntity(object o). I am figuring out which entity type it is on the server side using reflection and such and adding it to the database. I am using Self Tracki开发者_JAVA百科ng entities. However this is the error I am getting.

"Element contains data from a type that maps to the name . The deserializer has no knowledge of any type that maps to this name."

This is a lie. I have the entity on the server side, and I have the entity on the client side as a proxy. I am just passing it as an object because I have generalized the AddEntity method.

I am using object because generics are not serializable. So I cannot do something like this:

[OperationContract] AddObject(T entity)

Any suggestions are most welcome.


No. This is not how the WCF works. WCF serializes entity to wire format and deserializes the entity on the other side. Deserialization process needs to know what type have to be deserialized - such information is not part of serialized data. This type is resolved from operation parameter or return type. Object is not allowed.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜