WCF 服务参考不会重用现有程序集中的类型(VS 2010 Beta 2) [英] WCF Service Reference does not reuse types in existing assemblies (VS 2010 Beta 2)

查看:26
本文介绍了WCF 服务参考不会重用现有程序集中的类型(VS 2010 Beta 2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在 WCF 服务和客户端之间共享类型(实际的类,而不是代理)的最佳方法.为此,我在单独的程序集中定义了服务和客户端都引用的类.在客户端生成服务引用时,我选择了在所有引用的程序集中重用类型",但是 References.cs 是使用所有类的代理生成的.

I'm looking for the best approach to share types (the actual classes, not proxies) between a WCF service and a client. To that end, I defined the classes in a separate assembly that both service and client reference. I selected "Reuse types in all referenced assemblies" when generating the service reference in the client, but References.cs is generated with proxies for all classes.

这与这个问题完全相同,但我不知道如何实施已接受的解决方案.一个区别是我使用的是 VS 2010 Beta 2.

This is exactly the same question as this one, but I don't know how to implement the accepted solution. One difference is that I'm using VS 2010 Beta 2.

导入完整的服务合同以代码形式

import the complete service contract in code form

创建您自己的 ClientBase 派生类.真的很简单

create your own ClientBase-derived class. It's really very easy

假设这是最好的方法,我希望有一个很好的链接来介绍如何做到这一点.链接答案中概述的方法是最好的方法吗?

Assuming this is the best approach, I would appreciate a good link that covers how to do this. Is the approach outlined in the linked answer the best one?

推荐答案

我在同一步骤中做了两件事.不确定其中一个或两个是否解决了问题:

I did two things in the same step. Not sure if one or both resolved the problem:

  1. 向共享程序集中的一个类添加了 [DataContract(Namespace="My.Shared.Assemblys.Namespace")].
  2. 重新启动 VS 2010 Beta 2
  1. Added a [DataContract(Namespace="My.Shared.Assemblys.Namespace")] to one of the classes in the shared assembly.
  2. Restarted VS 2010 Beta 2

这篇关于WCF 服务参考不会重用现有程序集中的类型(VS 2010 Beta 2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆