Skip to main content

renaming default namespaces for VSTO projects in VS2008

So here is the scenario , you are starting a VSTO project and decided that your default namespace is ExcelAddInTesterApp . You created the project and started coding the project. After several days , your boss called and said "hey marvin , make use of this namespace OurCompany.ExcelAddInTesterApp , we have to add our company name to it got it?" . You get back to your machine thinking its just a simple property just like any project you've been working on. So you right clicked the VSTO project and hit properties . Boom! What the F@#$? The default namespace textbox is disabled!!!!

I've been through this and I googled for ways to do it and ended up with a blog from a Microsoft MVP telling me it can't be done because it is disabled. Then I thought of Refactoring, the beauty and grandeur of the renaming process. I selected the namespace and hit the refactor menu hoping that this would solve the problem . Unfortunately , it did not rather it displayed the message box below.

I have to do something, I cannot go back recreating theproject just to have the namespace changed. I tried the dirty Find Replace process. It worked . But since the default namespace of the project was not changed, adding new classes and items on the project would require a rename on the namespace. I would not want to do that, so I asked my officemate Fred if he have any ideas. He mentioned about tweaking the project file. So I opened the project file using notepad and manually changed some items that uses the name "ExcelAddInTesterApp". Below are images of what I've done.

So basically you will look for the "RootNamespace" item and change its value. Then search for the "GeneratedCodeNamespace" property and change it to a new value. Hitting save would save you a lot!! Look at the images below.

The default namespace was changed! So all new items added to the project would make use of the new namespace . What about the existing files that are using the old namespace , will they be automatically changed? The sad thing is that they are unchanged, so do the manual Find Replace process. Happy renaming….


Anonymous said…
Nice stuff! Thanks
Paul said…
This will break your add-in because the manifest is still referenced in to the old namespace.. Or atleast that is what happend on my project.
Anonymous said…
Really Nice...great work
Tom said…
Thank you, Works as expected!
Mikey said…
I did this, and then I did a clean/rebuild -- and it worked -- my manifest file appears to reflect the new namespace as well. Woot!
Mikey said…
I did this, and then I did a clean/rebuild -- and it worked -- my manifest file appears to reflect the new namespace as well. Woot!
Marvin Trilles said…
Glad it helped, man!
Anonymous said…
Thank you, thank you, thank you!!!
Anonymous said…
Saved me, even well after this was posted :)
murali karthik said…
Excellent post!!! The future of .net application development is on positive note. It offers huge career prospects for talented professionals all over the world. Training on .net technology will ensure good salary package. Best DOT NET Training institute in Chennai | DOT NET Training

Popular posts from this blog

Hiding Unwanted Python Folders and Files in Visual Studio Code

Visual Studio Code is a universal editor and pretty good at it. However, the explorer view maybe cluttered with the automatically generated folders and files confusing developers. Python is no different. Below are example files and folders generated by Python.

The __pycache__ folder and *.pyc files  are totally unnecessary to the developer. To hide these files from the explorer view, we need to edit the settings.json for VSCode. Add the folder and the files as shown below:
Copy and paste the lines below :


Getting Started with Stateless : A Lightweight Workflow Library Alternative for .NET

A year ago, I was looking for a simple workflow manager for a project I was working. Its a medium sized application that involves tracking the state of assets in the system. Back in 2008, Microsoft (MS) introduced new technologies along with the release of Visual Studio 2008: Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and Windows Workflow Foundation(WF). Having worked in a company utilizing mostly MS products for development, my first option was to go with WF. After doing some time reading and studying the library, I paused and decided it was too complex for my requirement. Using WF would be an overkill and the fact that it has, a rather, steep learning curve, there has to be another option. My mind toyed with the idea of developing a simple workflow library myself. It would be a learning experience but it might end up consuming a lot of time.

Why reinvent the wheel? So I started querying the internet for a better solution. I stumbled upon Stateless