更改要制作为 VS 项目模板的项目中 Web 引用的命名空间
当我向项目添加 Web 引用时,它会显示默认命名空间:com.wpdevs.myservice。这是我期望它在应用程序中使用的命名空间。
当我将 using 语句添加到项目中时,我必须添加:
using MyProject.com.wpdevs.myservice;
我想找到一种方法来消除在 using 语句中引用项目名称的情况。我现在整理的项目注定要转换为 VS 项目模板,并且其中有相当奇怪的引用,甚至有每个项目的引用,这不是我希望在项目中拥有的东西。
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.
When I add the using statement to the project, I have to add:
using MyProject.com.wpdevs.myservice;
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加 Web 引用时,您可以选择命名空间,但它将相对于项目的默认命名空间。我不知道有什么办法可以改变这一点。
OTOH,您可以尝试使用 WSDL.EXE 程序来生成代理类。它接受
/namespace
开关,允许您为代理类设置完整的命名空间。我必须知道您正在使用项目模板做什么,才能知道如何帮助您。
我正在根据您对项目模板的描述进行猜测。在创建模板时,您从一个名为“MyProject”的项目开始。当您将 Web 引用添加到该项目中时,使用的命名空间是“MyProject.something”。您希望从此模板创建的项目中使用的命名空间是“某物”。
虽然编辑生成的代码通常不是一个好主意,但在这种情况下,您可以摆脱它。编辑您的 Reference.cs 并手动将命名空间更改为“something”。然后,您将将该文件包含到项目模板中。使用此模板创建的项目将在“something”命名空间中具有 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, 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.
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".
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.