8

I always find my self in trouble with a lot of namespace or reference errors when trying to rename a project in VS.

This is how I do it: I click on the project and press F2 and rename it.

What procedure do you guys follow?

I used to work in Eclipse, and there I don't have the problems. Maybe it's easy in VS too and it's just me.

yoozer8
  • 7,361
  • 7
  • 58
  • 93
radbyx
  • 9,352
  • 21
  • 84
  • 127

3 Answers3

1

Try highlighting the root namespace in one of your files, and then hitting F2 and typing the new one in. This will perform a Refactor->Rename (also available via contextual menu), which should change that root namespace in all your files. Then, setting "Default Namespace" and renaming your project should take care of the rest.

drharris
  • 11,194
  • 5
  • 43
  • 56
0

Renaming the assembly should not be an issue, unless you have external projects depending on it. Within the same solution, it will carry on working correctly.

leppie
  • 115,091
  • 17
  • 196
  • 297
  • I have a project called "DatabaseAccessLayer" and lets say I change it too "DatabaseAccessLayer2", alle the namespaces for alle the classes in that project doesn't change but remain "namespace DatabaseAccessLayer...". And ofcourse it's the same thing for my Entity model. – radbyx May 18 '10 at 10:39
  • There is no easy way to rename namespaces that I know of. Unless some VS addins do it for you. You can try, carefully, find and replace using regular expressions. – Jacques Bosch May 18 '10 at 10:51
  • visual studio throws lots of errors if you simply rename the project. One has to follow systematic steps to have smooth renaming – RJN Jul 23 '20 at 16:45
0

In the properties for the project, I can set "Assembly name" and "Default namespace", I think it's what I've been look for. I assumed that the namespace was automatically renamed also in that proces.

If i'm still missing something, let me know so I can accept your answer.

radbyx
  • 9,352
  • 21
  • 84
  • 127