DarioN1
DarioN1

Reputation: 2552

Visual Studio inherits old namespace in a duplicated solution each time I add new cs file

I have created a new copy of a .net project following this steps:

  1. I have copied the project in a new folder
  2. Renamed the solution
  3. Renamed the sub folder
  4. Edited project file with a text editor and changed the path inside
  5. Renamed the namespace

All worked well, the project compiles and I can run it.

The problem is that each time I add a new file to the solution, it inherits the old namespace of the source project...

I have to rename the namespace each time I add a new cs file...

How can I fix the problem?

Thanks

Upvotes: 1

Views: 241

Answers (2)

Chris Catignani
Chris Catignani

Reputation: 5306

In addition to pm_2's answer...

I had a project I renamed. (Visual Studio 2017) Every time I copied an existing .aspx page, the new page and code behind file would have the old namespace names. In addition to pm_2's solution I had to make these changes also...

Checking in project file..

AssemblyInfo.cs:

View Properties Window.Ctrl+W,P Under your project...expand Properties. AssemblyInfo.cs is here.

Check the name(s) of

[assembly: AssemblyTitle("ProjectName")]
[assembly: AssemblyProduct("ProjectName")]

Upvotes: 1

Paul Michaels
Paul Michaels

Reputation: 16705

In the project properties, there is a default namespace box. It will use whatever is in this as the default.

default namespace

Upvotes: 4

Related Questions