WCF 数据服务代理类
我很确定这是一个愚蠢的问题,但无论如何。我有一个 WCF 数据服务公开一个对象,比如说 Person。此 Person 对象位于命名空间 Domain.Person 中。我有一个带有 WCF 数据服务代理的客户端。该客户端具有与引用的 Domain.Person 类一起使用的代码。但是,代理返回不同的类型 Client.Person,并且抱怨无法在两者之间进行转换。
那么,除了我很愚蠢(可能)之外,代理不是应该返回一种 Domain.Person 类型吗?如果不是,Client.Person 应该不一样吗?抱歉,有点混乱。
I am pretty sure this is a stupid question, but here goes anyway. I have a WCF Data Service exposing an object, let's say Person. This Person object is in the namespace Domain.Person. I have a client with a proxy to the WCF Data Service. This client has code that works with the referenced Domain.Person class. However, the proxy is returning a different type, Client.Person and it is complaining of being unable to convert between the two.
So, apart from me being stupid (likely), isn't the proxy supposed to return a type of Domain.Person? And if not, should the Client.Person not be the same? Sorry, bit confused.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有使用 WCF 数据服务的经验,但在我看来,代理生成了它自己版本的 Domain.Person 类并正在使用它。
添加“普通”wcf 服务引用时,可以指定在生成代理时可以重用其类型的程序集。它隐藏在您选择 WCF 服务的对话框中的“高级”按钮下方。
如果您确定已启用此功能,我会尝试打开生成的代理(通过显示所有文件,您可以看到生成的 .cs 文件)并将类型与您的域类型进行比较。如果存在任何显着差异,请将它们添加到您的域类型中,删除服务引用并再次添加。清洗-冲洗-重复...
同样,我对 WCF 数据服务的经验是不存在的,所以也许有人有更中肯的答案。
I have no experience with WCF Data Services, but it seems to me that the proxy generated it's own version of the Domain.Person class and is using this.
When adding a 'normal' wcf service reference, it is possible to specify assemblies from which types can be reused while generating the proxy. That's hidden under the 'Advanced' button on the dialog where you select your WCF service.
If you are sure that this is enabled, I'd try opening up the generated proxy (with show all files you can see the generated .cs file) and comparing the types to your Domain types. If there are any significant differences, add them to your Domain types, remove the service reference and add it again. Wash-rinse-repeat...
Again, my experience with WCF data services is non-existent, so maybe someone has a more to-the-point answer.