Hi All,
Is it possible to have a private namespace in VB? When I try it I get
this error:
"Specifiers and attributes are not valid on 'Namespace' statements."
I have a few reasons for wanting this; the most annoying one is that if
you add a web reference to your project, VS creates the proxy objects in
a namespace that you specify. Because namespaces are always public,
this then appears in the object browser as part of the component. But
this is annoying, because I don't want the internal implementation
details (i.e., that my component uses a web service) visible like this.
Namespaces are just an organizational convenience for the programmer;
I can't think of a reason why you shouldn't be able to make one public.
Any ideas on this one? Thanks in advance.
Cheers,
Josh
Marina - 28 Sep 2004 20:37 GMT
If the namespace is only applicable to that project - then why bother
creating it at all? Why not put the classes you would have put in there,
into one of the public namespaces in the project? As long as the classes
are marked as for the current assembly only, they should not show up
elsewhere.
> Hi All,
>
[quoted text clipped - 15 lines]
> Cheers,
> Josh
Joshua Frank - 28 Sep 2004 20:51 GMT
Agreed, but certain tools, like the web service proxy creator I
mentioned, auto generate code and put it in a namespace, so you don't
have the control that you need to do this. But also, once in a while it
would be nice to use a namespace for its intended purpose (i.e.,
organizing code) without publicizing this fact to everyone else.
> If the namespace is only applicable to that project - then why bother
> creating it at all? Why not put the classes you would have put in there,
[quoted text clipped - 21 lines]
>>Cheers,
>>Josh
Jonathan Allen - 28 Sep 2004 23:52 GMT
If you create a namespace "mystuff.private" and all the classes in it are
private, will anyone else ever see it?
I don't think they will, because the tools should not list empty namespaces.
Try it and see what happens.

Signature
Jonathan Allen
> Hi All,
>
[quoted text clipped - 15 lines]
> Cheers,
> Josh
Jay B. Harlow [MVP - Outlook] - 29 Sep 2004 03:18 GMT
Jonathan,
As you may know you can only put private classes inside another Class or
Structure.
The best you can do is make all the classes in "mystuff.private" Friend,
which then requires the namespace be written to the assembly, exposing the
namespace...
Interesting thought though, I had to try it to very verify it.
Hope this helps
Jay
> If you create a namespace "mystuff.private" and all the classes in it are
> private, will anyone else ever see it?
[quoted text clipped - 22 lines]
>> Cheers,
>> Josh
Joshua Frank - 29 Sep 2004 15:30 GMT
Right, you can make all the classes Friend, and they won't show up in
the Object Browser. But the namespace does. The empty namespace
doesn't do much harm, but it's untidy.
> Jonathan,
> As you may know you can only put private classes inside another Class or
[quoted text clipped - 35 lines]
>>>Cheers,
>>>Josh
Robert Jordan - 29 Sep 2004 18:52 GMT
> Right, you can make all the classes Friend, and they won't show up in
> the Object Browser. But the namespace does. The empty namespace
> doesn't do much harm, but it's untidy.
Namespaces don't exist in IL, nor do they exist in metadata.
They are just "shortcuts", that save us some time while typing
boring stuff like
ACME.Stuff.Util.Net.MultiSocket s = new
ACME.Stuff.Util.Net.MultiSocket();
Because they don't exist you cannot mark them hidden/private
whatever.
bye
Rob
>> Jonathan,
>> As you may know you can only put private classes inside another Class
[quoted text clipped - 37 lines]
>>>> Cheers,
>>>> Josh