Microsoft KB Archive/317098

= BUG: &quot;Sub Main was not found in WindowsApplication1.Form1&quot; error message when you change the Name property of a Startup Form in Visual Basic .NET =

Article ID: 317098

Article Last Modified on 2/3/2006

-

APPLIES TO


 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



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 &quot;WindowsApplication1.Form1&quot; (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.
 * 1) Click the General node in the Common Properties node, if it is not already selected.
 * 2) Click the Startup Object drop-down list box.
 * 3) Select the new name for the Startup Object drop-down list box.
 * 4) 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 &quot;Applies to&quot; section.



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 &quot;MyForm&quot; (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 &quot;Symptoms&quot; section in the task list.

Keywords: kberrmsg kbbug kbnofix kbvs2002sp1sweep kbvs2005swept kbvs2005doesnotapply KB317098

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.