将项目中的Web引用的命名空间更改为VS Project模板 [英] Changing the namespace for a Web Reference in a Project to be Made Into a VS Project Template

查看:82
本文介绍了将项目中的Web引用的命名空间更改为VS Project模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将Web参考添加到项目时,它带有默认名称空间:com.wpdevs.myservice.这是我希望它在应用程序中使用的命名空间.

When I add a web reference to a project, it comes up with a default namespace of: com.wpdevs.myservice. This is the namespace I'd have expected it to use in the application.

当我将using语句添加到项目中时,我必须添加:

When I add the using statement to the project, I have to add:

using MyProject.com.wpdevs.myservice;

我想找到一种消除在using语句中引用项目名称的方法.我现在放在一起的项目注定要转换为VS Project模板,并且在该项目中我不想拥有那个相当奇怪的引用,甚至没有每个项目的引用.

I'd like to find a way to eliminate having to reference the project name in the using statement. The project I'm putting together now is destined to be converted into a VS Project template and having that rather strange reference in there, or even having a per-project reference, isn't something I'd like to have in the project.

推荐答案

添加Web引用时,您可以选择名称空间,但是它将相对于项目的默认名称空间.我不知道有什么办法可以改变它.

When adding a web reference, you get to choose the namespace, but it will be relative to the default namespace of the project. I don't know of any way to change that.

OTOH,您可以尝试使用WSDL.EXE程序生成代理类.这接受/namespace开关,该开关允许您设置代理类的完整名称空间.

OTOH, you could try using the WSDL.EXE program to generate your proxy classes. This accepts a /namespace switch that allows you to set the full namespace for the proxy classes.

我必须知道您对项目模板的处理方式,才能知道如何为您提供帮助.

I would have to know what you were doing with your project template to know how to help you with that.

我正在根据您对项目模板的评价进行猜测.在创建模板时,您从一个名为"MyProject"的项目开始.当您将Web参考添加到该项目时,使用的命名空间是"MyProject.something".您希望从此模板创建的项目中使用的命名空间是某物".

I'm making a guess based on what you say about your project template. In creating the template, you started with a project named "MyProject". When you added a web reference into that project, the namespace used was "MyProject.something". You'd like the namespace used in projects created from this template to be "something".

尽管编辑生成的代码通常不是一个好主意,但是在这种情况下,您可以摆脱它.编辑您的Reference.cs并手动将名称空间更改为"something".然后,您将把该文件包含到项目模板中.使用此模板创建的项目将在某物"命名空间中具有Web参考.

Although it's not normally a good idea to edit generated code, in this case, you can get away with it. Edit your Reference.cs and manually change the namespace to "something". You'll then include that file into the project template. Projects created using this template will have a web reference in the "something" namespace.

这篇关于将项目中的Web引用的命名空间更改为VS Project模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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