All, I have an application I want to lanch from another application or as a stand alone utility. To facilitate the start up of appA from appB, I use the following code in Main()
/Program.cs
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SqlEditorForm(args));
}
Now, in SqlEditorForm
I have two constructors
public SqlEditorForm(string[] args)
: this()
{
InitializeComponent();
// Test if called from appB...
if (args != null && args.Count() > 0)
{
// Do stuff here...
}
}
and the deafult
public SqlEditorForm()
{
// Always do lots of stuff here...
}
This to me looks fine, but when run as stand alone (args.Length = 0
) the SqlEditorForm(string[] args)
constructor is getting called, and before it steps into the constructor to perform InitializeComponent();
, it goes and initialises all of the global variables for the class then steps directly into the default constructor.
Question, The chaining of the constructors seems to be happending in the wrong order. I want to know why?
Thanks for your time.