“重用现有类型"添加服务引用时被忽略 [英] "Reuse existing types" is ignored when adding a service reference

查看:25
本文介绍了“重用现有类型"添加服务引用时被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向 Visual Studio 2008 中的一个项目添加服务引用.在服务引用设置"屏幕上,我选择了重用所有引用程序集中的类型"的默认选项.我已经引用了我想要重用类型的项目.该类型作为参数传递给 Web 方法.

I am adding a service reference to one of my projects in Visual Studio 2008. On the "Service Reference Settings" screen I am selecting the default option which says "Reuse types in all referenced assemblies". I have referenced the project for which I want to reuse a type. That type is being passed in as a parameter to a web method.

但是,在生成 References.cs 文件时,它仍会创建该类型的重复代理版本.有什么我想念的吗?你需要对引用的类型做任何特殊的事情吗?也许添加一些特殊属性?

However, when the References.cs file is generated, it still creates a duplicate proxy version of that type. Is there something I am missing? Do you need to do anything special to the referenced type? Perhaps add some special attributes?

推荐答案

我已经回答了我自己的问题(我认为).我试图做的是使用服务引用来指向现有的 ASP.NET Web 服务,但旧式 Web 服务不支持重用类型.它仅适用于 WCF 服务.所以我冒险尝试将我的 Web 服务转换为真正的 WCF 服务,现在它可以正常工作了.

I've answered my own question (I think). What I was trying to do was use a service reference to point to an existing ASP.NET web service, but reusing types is not supported for old school web services. It only works with WCF services. So I took the plunge and converted my web service to a true WCF service and now it works fine.

这篇关于“重用现有类型"添加服务引用时被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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