WCF problem with custom types
I have created two projects in the same solution. The first project has a class, lets call it "class A". The second project is a WCF service library. That WCF service is referencing开发者_运维知识库 a project from that same solution so it can use type "A" defined in the first solution.
Now, the problem is that when I reference that wcf service from the first project (normal C# project), in the object browser I see wcf service methods that have to return type "A", are returning just an "object" type! If I define a custom class as part of WCF project, it is recognized as return type.
How can I make project 1 (that defined type "A") use the WCF project and recognize his own types?
You will probably have to mark your DataContracts with [KnownType]
.
And it is a (very) good idea to isolate those shared types in a separate assembly (Project).
If you are the only consumer of your services and is a .net application then it might be worth using the NetDataContractSerailizer
this way you can pass shared type information and you don't need to mark your objects with [KnownType]
see here for better explanation http://www.pluralsight-training.net/community/blogs/aaron/archive/2006/04/21/22284.aspx
hth
精彩评论