Application will terminate when Sub Main() finishes.

    Standard EXE applications written in VB6 can be started either from a Main sub or a startup form which is set in the project properties. The use of the Main sub is a very common practice in large applications, because it allows the execution of initialization logic before the load of the main form of the application, and allows a separation of this logic from the logic of the form.

    When an application that uses the Main sub as startup object is migrated using the VBUC, equivalent code is generated in .NET, however, due to differences in the behavior of VB6 and the .NET Framework the applications behave differently. Some manual changes are required to achieve functional equivalence in this case.

    In VB6, all the code in the Main sub is executed and the method ends, but the application continues to run while a form is displayed. In .NET on the other hand, the application will exit as soon as the Main method exits, any open form at that point will be closed automatically.

    See also: How to prevent the application from exiting immediately after starting?

    Sample VB6

    Public Sub Main()
        Dim x As Integer
        x = 10
        MsgBox x
    End Sub

    Target VB.NET

    'UPGRADE_WARNING: (1047) Application will terminate when Sub Main() finishes.
    <STAThread> _
    Public Sub Main()
    	Dim x As Integer = 10
    	MessageBox.Show(CStr(x), My.Application.Info.Title)
    End Sub

    Target C#

    //UPGRADE_WARNING: (1047) Application will terminate when Sub Main() finishes.
    public static void Main()
    	int x = 10;
    	MessageBox.Show(x.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));

    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration