0

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?

3
  • Your mixing up the words Solution and Project. You'll have to be more precise in this question. And describe the setup a little better too. Are the Types (assembly) shared between Client and Server? Commented Jul 4, 2011 at 18:12
  • One solution contains two projects - client app (client project) and server app (wcf project). WCF project has to use types defined in client project (part of same solution) and it's ok, but when those types have to be offered to client app (in the same solution, that defines types used bu wcf) those types are recognized as "object". Don't know how to describe it any better :) Commented Jul 4, 2011 at 18:16
  • 1
    Client app defines types exposed by the service? That smells. Commented Jul 4, 2011 at 18:31

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Problem with my code was that i was trying to communicate with WCF using interfaces (whole project 1 is using interfaces as function argument types and return types). Right now, i realized i can't use interfaces that way, but when when i use class from project 1 to communicate with wcf that class (in object browser) is described as "WCFProject class", not as class belonging to "Project1"!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.