views:

1017

answers:

2

I have no intention of using "My" for anything in any of my projects. I haven't done anything with it (that I know of). But every one of class libraries shows a "My" namespace in Reflector and NDepend. This adds a lot of unnecessary clutter.

1) Why does it show up?

2) How can I remove it?

+1  A: 

"My" is a feature added in Visual Studio 2005 for VB.Net. The intention of the feature is to give users more of the API feel they were accustomed to with VB6. It includes many of the most popular functions and helper classes.

Here is a MSDN article which goes into more detail: http://msdn.microsoft.com/en-us/magazine/cc163972.aspx

AFAIK, there is no way to disable this feature in VB.Net as of VS 2008.

JaredPar
I know what the My namespace is. It just seems odd that MyCustomLibrary.dll should contain what looks like generated Friend classes.
Larsenal
there actually is a way to remove it
Tom Anderson
I love My namespace!
Shimmy
+7  A: 

Steps to remove the "My" Namespace

  • In the project properties, turn off "Enable application framework"
  • Under advanced compile options, turn on "Enable Optimizations"
  • Show all files in the project
  • Delete the Application.myapp node, Resources.resx, and Settings.settings nodes.
  • Unload the project, open the .vbproj in notepad, change the <MyType> to <MyType>Empty</MyType>
  • Reload the project and compile.

For resources, use standard resource files and their constructors (My just did a wrapper of this).

For Settings, use the config file.

Tom Anderson
Where is the <MyType> found?
Larsenal
in the .vbproj, open it in notepad, added clarification.
Tom Anderson
OMG... Thank you Tom. This (along with the "Not Is Nothing") was a source of great irritation. +1
StingyJack
In the Application Tab of Project Properties, "Enable application framework" is greyed out. I assume that's OK. I've done everything else, but my assembly still shows MyApplication, MyComputer and MyProject. But it is better than before.
Larsenal
You need to change the MyType in the actual .vbproj file (it is xml and can be opened in notepad) to "Empty" not "". Sorry if the clarification was wrong.
Tom Anderson
Awesome! It worked. My greatest thanks!
Larsenal
How do I disable it using the command line? Without the IDE?
Alex