开发者

Getting class type from WCF service

In my client, I'm trying to declare an entity type from the service....

MyService.MyClass myClass = new MyService.MyClass();
....

MyClass isn't available.

The assemb开发者_JAVA百科ly MyClass is within is referenced by MyService. What am I missing?


Generally, to preserve the service boundary, you work with mex-generated proxy classes at the client; these are structure only, so don't have any methods etc (just properties), and may even have different names (and almost certainly a different namespace).

However; if this .NET to .NET, you can get WCF (via either svcutil or the IDE) to re-use types in existing assemblies. Via the IDE it does this automatically (by default - you can disable it) if you have a reference to a dll containing matching types. At the command line, you use /r IIRC.


From the client's perspective, the service is just the interface, the client doesn't have access to the guts of the server. The types you might need should be exposed as part of a contract externally (like in a seperate assembly).


You probably want to Add Service Reference. Note that the generated class will have a slightly differnt name/namespace to your server implementation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜