服务引用不生成客户端类型 [英] Service reference not generating client types

查看:151
本文介绍了服务引用不生成客户端类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过添加服务引用它消耗在类库的WCF服务。在类的图书馆之一它被消耗正常,我可以访问客户端类型,以便产生过他们的代理。然而,在我的第二个类库(甚至在控制台测试应用程序),当我添加相同的服务引用,它只是暴露了所涉及的承包经营,而不是客户端类型对我产生对代理的类型。

I am trying to consume a WCF service in a class library by adding a service reference to it. In one of the class libraries it gets consumed properly and I can access the client types in order to generate a proxy off of them. However in my second class library (or even in a console test app), when i add the same service reference, it only exposes the types that are involved in the contract operations and not the client type for me to generate a proxy against.

例如。端点有2个服务公开 - ISvc1和ISvc2。当我添加一个服务引用此端点在第一类库我得到ISvc1Client ANDF ISvc2Client,以便通过使用这些2合同公开的操作生成代理过的。除了这些客户端的服务引用也暴露出参与操作,如类型(1型,2型等),这正是我所需要的。然而,当我尝试添加服务引用到同一endpoing在另一个控制台应用程序或类库只有1型,2等接触,而不是ISvc1Client和ISvc2Client因其中我无法生成一个代理来访问我所需要的操作。我无法确定为什么服务引用才能正确生成一个类库,但不是在其他或测试控制台应用程序。

e.g. Endpoint has 2 services exposed - ISvc1 and ISvc2. When I add a service reference to this endpoint in the first class library I get ISvc1Client andf ISvc2Client to generate proxies off of in order to use the operations exposed via those 2 contracts. In addition to these clients the service reference also exposes the types involved in the operations like (type 1, type 2 etc.) this is what I need. However when i try to add a service reference to the same endpoing in another console application or class library only Type 1, Type 2 etc. are exposed and not ISvc1Client and ISvc2Client because of which I cannot generate a proxy to access the operations I need. I am unable to determine why the service reference gets properly generated in one class library but not in the other or the test console app.

推荐答案

显然,你需要添加服务引用前添加引用System.Web程序在你的项目。这做到了。

Apparently you have to add a reference to System.Web in your project before adding the Service Reference. That did it.

这篇关于服务引用不生成客户端类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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