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

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

问题描述

我正在尝试通过向类库中添加服务引用来使用该服务.在其中一个类库中,它被正确使用,我可以访问客户端类型以从中生成代理.但是,在我的第二个类库中(甚至在控制台测试应用程序中),当我添加相同的服务引用时,它只公开合同操作中涉及的类型,而不公开客户端类型以供我生成代理.

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.

例如Endpoint 公开了 2 个服务 - ISvc1 和 ISvc2.当我在第一个类库中添加对这个端点的服务引用时,我让 ISvc1Client 和 f ISvc2Client 生成代理,以便使用通过这两个合同公开的操作.除了这些客户端之外,服务引用还公开了操作中涉及的类型,例如(类型 1、类型 2 等),这正是我所需要的.但是,当我尝试在另一个控制台应用程序或类库中添加对同一端点的服务引用时,仅公开了类型 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天全站免登陆