Master_T
Master_T

Reputation: 7913

Can't change a project's Default Namespace in Visual Studio 2013

I have a solution that includes various C# projects, and I just now noticed that I can't change the default namespace on any of them.

When I go to Properties --> Application on any of the project and change the "Default Namespace" field, a fatal error dialog pops up that says:

exception of type 'system.runtime.interopservices.externalexception' was thrown

At this point Visual Studio becomes unusable, as I can't close it or leave the screen, every click or button combination I press makes the same dialog pop up. The only thing I can do is terminate VS with the task manager.

Upvotes: 15

Views: 9570

Answers (3)

Adrian von Allmen
Adrian von Allmen

Reputation: 341

I had to investigate the issue in our company and I found another workaround in our case. So I think it make sense to add it here.

Possible Solution

Check if you have more than one suo-File for the project/solution and delete the one which doesn't has the ".v12.suo" naming (better delete both)

Story behind:

We still have two Visual Studio installed (2010 and 2013) and some of our developer worked recently on 2010. So they had on the file system a regular ".suo"-File. Afterwards (some weeks later) they started to use 2013 (which created a ".v12.suo"-File).

We renamed both suo files, started VS2013 (which created the v12.suo) and were able to rename the namespace without a crash. In addition we had this issue not on all solutions. I didn't see yet a pattern, but in our case it happened mostly on solution with at least two projects and referenced project-libraries.

Upvotes: 0

MichelZ
MichelZ

Reputation: 4394

I got around it by just renaming the <RootNamespace> node in the .csproj file

Upvotes: 26

Paweł Bejger
Paweł Bejger

Reputation: 6366

Maybe you should try to do this in another way:

Ctrl-H - Find: PreviousNameSpaceName Replace: NewNamespaceName

You can also right click the namespace in code and Refactor->Rename.

What is more: you can change the names of your projects, solutions, directories - etc. Namespaces, when adding new files, are generated using these names in fact.

Upvotes: 3

Related Questions