Could not find 'WindowsFormsApplication1.Program' specified for Main method after renaming name space

C#Visual Studio-2010Namespaces

C# Problem Overview


I have a C# app that had the default namespace WindowsFormsApplication1.

I decided that I would like to use a different namespace so I renamed WindowsFormsApplication1. Now when I compile I get the error:

> Could not find 'WindowsFormsApplication1.Program' specified for Main > method.

To rename the namespace I highlighted the namespace in a file and hit F2.

How do I resolve this and change the actual namespace through out the project?

I am using Visual C# 2010 Express.

C# Solutions


Solution 1 - C#

In project -> properties change "startup object" to the new namespace.

Select Startup Object

Solution 2 - C#

You should rename through the "Refаctor" feature of Visual Studio.

Solution 3 - C#

As Mausimo says you need to select the 'Startup object' in Project -> References, however I was finding that the new namespace was not being shown here; I could only select the old namespace or '(Not set)'. If you find the same then it appears VS (this is on 2013) does not pick up the change immediately, restart VS and you can then select the class under the new namespace.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMausimoView Question on Stackoverflow
Solution 1 - C#MausimoView Answer on Stackoverflow
Solution 2 - C#Stecenko RuslanView Answer on Stackoverflow
Solution 3 - C#d219View Answer on Stackoverflow