Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the namespace for a Web Reference in a Project to be Made Into a VS Project Template

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.

like image 439
kdmurray Avatar asked Mar 14 '10 06:03

kdmurray


1 Answers

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.

like image 56
John Saunders Avatar answered Sep 28 '22 23:09

John Saunders