user281812
user281812

Reputation: 195

Change project name from default "Application1" name

I have a WPF project written with C# with project name of "Application1". I want to change this name which is also the namespace of my project class.

Can i do it from project properties? I want to change it to resonable name. I tried to do it from code behind with no success.

Is the namespace is taken automatically from project name?

namespace Application1
{
    public partial class MainWindow : Window
    {
    }
}

Upvotes: 3

Views: 8416

Answers (4)

Rukshan Dangalla
Rukshan Dangalla

Reputation: 2590

I know this is old. But recently I also wanted to do the same and change application name in the toast notification. My scenario is bit different but hope this will help.

This is what I got in the beginning:

enter image description here

But I wanted to change it to this:

enter image description here

So I achieved desired result by changing AssemblyInfo.cs under properties of my wpf application.

In there I changed AssemblyTitle & AssemblyProduct Hope this will help :)

Upvotes: 2

Arie
Arie

Reputation: 5373

Rename the project:

right-click the project and rename

Rename the default namespace of the project:

double-click project's properties, choose the Application tab, then change what you need:

  • Assembly name
  • Default namespace
  • click Assembly information and change Title and Product

Rename the namespace in code-behind (you need to make sure you do it everywhere):

  • rename the namespace in all .cs and .xaml.cs files (for example when you click App.xaml node in your project, there will be App.xaml.cs class)

  • rename the namespace in all .xaml files, for example in your MainWindow.xaml and App.xaml (you need to change x:Class="MyNewNamespaceName.App" or x:Class="MyNewNamespaceName.MainWindow"):

Upvotes: 0

Luca
Luca

Reputation: 1826

1.) To rename a solution

In Solution Explorer, right-click the solution node and then select Rename from the context menu.

Type the new name for your solution.

2.) To rename a project

In Solution Explorer, right-click the project node and then select Rename from the context menu.

Type the new name for your solution.

3.) And last but not least for the Namespace:

-> Project -> Properties -> Default Namespace

Other than that,

Ctrl-H - Find: Application1 Replace: MyName

Source: How to: Rename Solutions, Projects, and Items

Upvotes: 5

MajkeloDev
MajkeloDev

Reputation: 1661

You can change the project name like right click on the project in Solution Explorer -> rename. And You can change namespace like ctrl + h then in top TextBox write

namespace Application1,

in second

TextBox write namespace YourNewname

From the listbox choose "replace in whole solution"(something liek that) and proceed.

Upvotes: 0

Related Questions