Startup object

  • Thread starter Thread starter cj
  • Start date Start date
C

cj

In 2003 I sometimes changed the startup object of a project to Sub Main
which was found in Module1.vb. I upgraded one such project to 2005 and
I notice in the properties page for the project that nothing is selected
as the startup object. It appears to function but should I set it to
Sub Main?
 
I just noticed on projects created from scratch in 2005 the checking and
unchecking of "enable application framework" affects this. Can anyone
point me to some basic and brief info on how this relates to what I was
used to in 2003? I'm Googling now.
 
Deep voodoo. And it'll probably all change again in a couple of years.
They'll be promoting a new, better and very different way of doing things.
 
I also checked.

C# does a nice little Program.cs thing for you:

Ahhhhh! VB.Net 2005 just took a dufous step back to vb6/vb5/vb4. I can't
speak past vb4.





using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace MyApp

{

static class Program

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new MainForm());

}

}

}
 
MS thinks WinForm applications should always start with a form.

So in VB2005, if you want to start with a static method
(Sub Main), you can do that, but MS assumes it's not going to be
a WinForm application. Just select the class name that contains
the Sub Main in the Startup Object combo box on the Application
page of the My Project designer.

For this option to be available, you have to have the
Enable Application Framework option disabled, because
that is used for Windows Forms applications.

You can enable the XP styles manually if you choose to do so.
According to Francesco Balena's "Standard Practices" book, you
should invoke Application.DoEvents right after enabling the
visual styles because there's some bug in int. They may have
fixed this in VB2005, though. He gives a link:
http://www.codeproject.com/buglist/EnableVisualStylesBug.asp

Robin S.
------------------------------------------------------
 
Hi Cj,

About the startup object, VS2005 is compatible with VS.NET 2003.

In VS.NET 2003, we could select a form or a module that contains Sub Main
procedure, or just Sub Main if Sub Main procedure is declared only once in
the project, as the startup object.

It's same in VS2005. In addition, VS2005 instroduce a new option of 'Enable
application framework' which specifies whether or not a Windows application
project will start with a custom Sub Main procedure (that you have
created).

If you enable the application framework, your application uses the standard
Sub Main. If you disable the application framework, your application could
use the custom Sub Main.

When a VS.NET 2003 Windows application project is upgraded to VS2005, the
startup object remains unchanged. However, the problem is that if we set
Sub Main as startup object in the VS.NET 2003 project and then upgrade it
to VS2005, the 'Startup object' option in the project designer is not set.
I have performed a test and confirmed this. I also found that if I set the
startup object to a form or a module, the form or module is set as the
startup object in the project designer in upgraded project.

I think this may be a limitation of VS2005 when upgrading projects.
Although it still functions, I suggest that you set the startup object to
Sub Main or some other things in the project designer for the upgraded
project, lest this may cause confusion for other developers.

Hope this helps.
If you have anything unclear, please feel free to let me know.



Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks!
MS thinks WinForm applications should always start with a form.

So in VB2005, if you want to start with a static method
(Sub Main), you can do that, but MS assumes it's not going to be
a WinForm application. Just select the class name that contains
the Sub Main in the Startup Object combo box on the Application
page of the My Project designer.

For this option to be available, you have to have the
Enable Application Framework option disabled, because
that is used for Windows Forms applications.

You can enable the XP styles manually if you choose to do so.
According to Francesco Balena's "Standard Practices" book, you
should invoke Application.DoEvents right after enabling the
visual styles because there's some bug in int. They may have
fixed this in VB2005, though. He gives a link:
http://www.codeproject.com/buglist/EnableVisualStylesBug.asp

Robin S.
 
Back
Top