Change Project Namespace in Visual Studio

Visual Studio

Visual Studio Problem Overview


How can I change the project namespace in Visual Studio?

The namespace is currently WindowsFormsApplication16, and I want the namespace to be MyName.

Visual Studio Solutions


Solution 1 - Visual Studio

You can change the default namespace:
-> Project -> XXX Properties...
On Application tab: Default namespace

Other than that:
Ctrl-H
Find: WindowsFormsApplication16
Replace: MyName

Solution 2 - Visual Studio

Instead of Find & Replace, you can right click the namespace in code and Refactor -> Rename.

Thanks to @Jimmy for this.

Solution 3 - Visual Studio

Assuming this is for a C# project and assuming that you want to change the default namespace, you need to go to Project Properties, Application tab, and specify "Default Namespace".

Default namespace is the namespace that Visual studio sets when you create a new class. Next time you do Right Click > Add > Class it would use the namespace you specified in the above step.

Solution 4 - Visual Studio

"Default Namespace textbox in project properties is disabled" Same with me (VS 2010). I edited the project file ("xxx.csproj") and tweaked the item. That changed the default namespace.

Solution 5 - Visual Studio

Just right click on the name you want to change (this could be namespace or whatever else) and select Refactor->Rename...

Enter new name, leave location as [Global Namespace], check preview if you want and you're done!

Solution 6 - Visual Studio

Right click properties, Application tab, then see the assembly name and default namespace

Solution 7 - Visual Studio

First)

  1. Goto menu: Project -> WindowsFormsApplication16 Properties/
  2. write MyName in Assembly name and Default namespace textbox, then save.

Second)

  1. open one old .cs file ( a class or a form)
  2. right click on WindowsFormsApplication16 in front of namespace, goto Refactor -> Rename .
  3. write MyName in New name textbox, in Rename Message Box.
  4. press Ok, then Apply

Solution 8 - Visual Studio

In visual studio right-click on your project then select Edit Project File or open the .csproj file directly then inside the <PropertyGroup> tag write the following tag

<RootNamespace>YourNamespaceName</RootNamespace>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser319854View Question on Stackoverflow
Solution 1 - Visual StudioKyle RosendoView Answer on Stackoverflow
Solution 2 - Visual StudioYasser ShaikhView Answer on Stackoverflow
Solution 3 - Visual StudioIgor ZevakaView Answer on Stackoverflow
Solution 4 - Visual StudioGary HuckaboneView Answer on Stackoverflow
Solution 5 - Visual StudioSzybkiView Answer on Stackoverflow
Solution 6 - Visual StudioJason JongView Answer on Stackoverflow
Solution 7 - Visual StudioPedPakView Answer on Stackoverflow
Solution 8 - Visual StudioAhmed HanyView Answer on Stackoverflow