Click here to Skip to main content
15,914,165 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working on a huge project and went to change the namespace which worked, then I refactored the code which worked for only a few class files so now I have different namespaces in some files and original namespaces in others. The project now will not build. I cannot undo and I need a way to change the WHOLE namespace (some of them are one namespace and some are a different one, both which i want to change to 1 which is the same) not just one of the symbols like refactoring does. Please help me I am coding in C# and Visual Studio 2010 Express so I can't use resharper. Thank You
Posted
Updated 25-Sep-13 21:22pm
v3

Hi,

You may want to change default namespace from project properties if you haven't already done that, it will help new files to fall under new namespace by itself. you may want to modify your assembly info as well there (as our friend has mentioned in comment, it's not important. my understanding is that if you are trying to refactor your code, you should look here as well).

As for your existing files, Am afraid you may have to change namespace manually if you are not using refactoring (well i meant using refactoring engine to change name, but as a friend rectified in comment, i do agree refactoring is not just changing name. and visual studio does a great job, you don't need re-sharper).

Yes you can still work with your application with code being in different namespaces, as namespace is for better code organization.

If you are having issues building solution after changing namespaces, recheck your project which is failing for references. i had similar issue when i had to change namespace for our application with multiple projects, i happened to resolve it by fixing references with new namespace. i used a tool called "agent ransack" to find and fix issues with false references. may be it will help you.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 26-Sep-13 3:49am    
No, no. First, OP never say he would not use refactoring. (By the way, "refactoring" does not mean using refactorization engine, but OP also did not say he would not use it; he probably has a misconception about its work.)

And, importantly, default namespace is irrelevant to the problem, totally. It only helps to get certain namespaces when code is auto-generated.

So, totally misleading answer.

—SA
You don't have to use Resharper. Standard refactorication engine which comes with Visual Studio does this job perfectly. I have no idea why you say "like refactoring does". It does it all correctly.

And you absolutely don't need to change default namespace of any of the assembly. This is just one of the project settings, it does not affect application behavior whatsoever. It just affect the behavior of Visual Studio, just a bit: when you add a class (or any other auto-generated code), the code is written according to this default assembly. If you forgot to modify this option, you can change any namespace at any time; you can even ignore the problem.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900