BUG: "Sub Main was not found in WindowsApplication1.Form1" error message when you change the Name property of a Startup Form in Visual Basic .NET (317098)



The information in this article applies to:

  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

This article was previously published under Q317098

SYMPTOMS

If you change the Name property of a Startup Form in Visual Basic .NET, you may receive the following error message when you run or build the project:
'Sub Main' was not found in 'WindowsApplication1.Form1'
The "WindowsApplication1.Form1" (without quotation marks) part of the error message might be different depending on your project's root namespace and the name of your Startup Form.

CAUSE

This problem can occur because the Startup Object property for the project is not updated to the new form name.

RESOLUTION

To resolve this problem, change the Startup Object property for the project to the new form name. To do this:
  1. Right-click the Startup project in Solution Explorer.
  2. Click Properties when you receive the context menu.

    The Property Pages dialog box appears.
  3. Click the General node in the Common Properties node, if it is not already selected.
  4. Click the Startup Object drop-down list box.
  5. Select the new name for the Startup Object drop-down list box.
  6. Click OK.
NOTE: You can also open the Property Pages dialog box by clicking Properties on the Project menu, or by pressing the Shift+F4 keys. For this to work, the Startup project should be selected in the Solution Explorer.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to Reproduce the Problem

  1. Create a Visual Basic .NET Windows Application project, Form1 is created by default.
  2. Click Form1, and then press the F4 key to display the Properties window for Form1.
  3. Change the Name property for Form1 to "MyForm" (without quotation marks). You can change the name to any valid name.
  4. Press the F5 key to run the project.
  5. Click No when you receive a build error dialog box, and you will receive the error message that is mentioned in the "Symptoms" section in the task list.

Modification Type:MinorLast Reviewed:2/3/2006
Keywords:kbvs2005doesnotapply kbvs2005swept kbvs2002sp1sweep kbbug kberrmsg kbnofix KB317098