且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在.NET远程处理和WCF中使复杂的类型对客户端可见?

更新时间:2022-01-30 00:54:36

您好,

这似乎很愚蠢,但似乎您已将接口放入* server *应用程序中.这当然是可能的,但是将要求客户端对服务器进行引用.通常,您不希望将服务器部署在客户端计算机上:),因此可以将接口放在一个通用程序集中,以便同时在客户端和服务器上进行部署.

也就是说,如果您复制了接口声明,以便该代码同时存在于客户端和服务器程序集中,这就是您的问题-它的确应导致InvalidTypeCastException.
Hi,

this may seem silly but it looks as if you''ve put the interfaces in the *server* application. This is certainly possible, but would require the client to have a reference to the server. Normally one doesn''t want to deploy the server on the client machine :) so one would put the interfaces in a common assembly to be deployed on both client and server.

That said, if you have duplicated the interface declarations so that the code exists in both client and server assemblies then that is your problem - and it should indeed result in InvalidTypeCastException.