I have a Visual Studio 2010 Solution with 3 projects: Shared, which contains a single class called ServiceResult
. The class is attributed with DataCon开发者_开发技巧tract(IsReference=true)
, and each property is attributed with DataMember
. The next project is a WCF service, with a method that returns the ServiceResult
type. The third project is a command line app with a Service Reference to the WCF service. This also has a reference to the Shared project.
No matter what I do, if the DataContract
attribute is on the ServiceResult
class, I don't get my proxy client in the console application. As soon as I replace the DataContract
attribute with the Serializable
attribute, and refresh my service reference, I get my proxy client in the command line app.
I'd like to have this class attributed with the DataContract
attribute, as I want to take advantage of the IsReference
property to maintain object references.
Has anyone seen anything like this before, and if so, how did you solve it?
Thanks!
I should add that the ServiceResult class is a generic type:
[DataContract(IsReference=true)]
public class ServiceReferences<TReturn>{...}
Actually, he, I didn't realize that I can't serialize generic types, while at the same time, referencing the the same custom type client side. The client proxy wanted to use a type called ServiceResultOfInt, but the client code was using ServiceResult<int>. Problem solved. Thanks, though!
精彩评论