views:

184

answers:

1

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.

+2  A: 

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.

John Saunders
kdmurray
Editing the generated files is precisely what I did after I read your first suggestion. Figured if you can change the namespace with a parameter, it must be editable too. Works like a charm. Thanks!
kdmurray