WinForm Startup Error

  • Thread starter Thread starter ShadowMan
  • Start date Start date
S

ShadowMan

I am getting an "'Application' is an ambiguous reference" error when I try
to start my WinForms appllication. How can the Application object be
ambiguous? Any ideas what I did wrong? Thanks.

I am using C# and VS2003.
I have declared references:
using System;
using System.Windows.Forms;
using System.ComponentModel;

The error occurs in:

[STAThread]
public static void Main()
{
try
{
Global.MainForm = new frmMain();
Application.Run(Global.MainForm); <======== 'Application' is
an ambiguous reference

SetupSplashScreen();
GetConfigurationData();
if(ValidDB)
{
InitializeObjects();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "MainForm",MessageBoxButtons.OK,
MessageBoxIcon.Stop);

}

}
 
Hello ShadowMan,

Perhaps you've created another class in the same namespace called Application.

Try modifying your line to read:

System.Windows.Forms.Application.Run(Global.MainForm);
 
Matt,

Thanks for the response. I figured out that I had to explicitly qualify
Application after I had sent the post. I am still not sure why I have to do
this. I don't have another "Application" class in my namespace or solution.
Another mystery of life ;-)


Matt Berther said:
Hello ShadowMan,

Perhaps you've created another class in the same namespace called
Application.

Try modifying your line to read:
System.Windows.Forms.Application.Run(Global.MainForm);

--
Matt Berther
http://www.mattberther.com
I am getting an "'Application' is an ambiguous reference" error when I
try to start my WinForms appllication. How can the Application object
be ambiguous? Any ideas what I did wrong? Thanks.

I am using C# and VS2003.
I have declared references:
using System;
using System.Windows.Forms;
using System.ComponentModel;
The error occurs in:

[STAThread]
public static void Main()
{
try
{
Global.MainForm = new frmMain();
Application.Run(Global.MainForm); <========
'Application' is
an ambiguous reference
SetupSplashScreen();
GetConfigurationData();
if(ValidDB)
{
InitializeObjects();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,
"MainForm",MessageBoxButtons.OK,
MessageBoxIcon.Stop);
}

}
 
If you take out the explicit qualification, and then remove the "using
System.Windows.Forms" line, and then right click Application and choose Go
to Definition, it should indicate where the other "Application" is.

ShadowMan said:
Matt,

Thanks for the response. I figured out that I had to explicitly qualify
Application after I had sent the post. I am still not sure why I have to
do this. I don't have another "Application" class in my namespace or
solution. Another mystery of life ;-)


Matt Berther said:
Hello ShadowMan,

Perhaps you've created another class in the same namespace called
Application.

Try modifying your line to read:
System.Windows.Forms.Application.Run(Global.MainForm);

--
Matt Berther
http://www.mattberther.com
I am getting an "'Application' is an ambiguous reference" error when I
try to start my WinForms appllication. How can the Application object
be ambiguous? Any ideas what I did wrong? Thanks.

I am using C# and VS2003.
I have declared references:
using System;
using System.Windows.Forms;
using System.ComponentModel;
The error occurs in:

[STAThread]
public static void Main()
{
try
{
Global.MainForm = new frmMain();
Application.Run(Global.MainForm); <========
'Application' is
an ambiguous reference
SetupSplashScreen();
GetConfigurationData();
if(ValidDB)
{
InitializeObjects();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,
"MainForm",MessageBoxButtons.OK,
MessageBoxIcon.Stop);
}

}
 
Thanks Sean. That's good to know!


Sean Hederman said:
If you take out the explicit qualification, and then remove the "using
System.Windows.Forms" line, and then right click Application and choose Go
to Definition, it should indicate where the other "Application" is.

ShadowMan said:
Matt,

Thanks for the response. I figured out that I had to explicitly qualify
Application after I had sent the post. I am still not sure why I have to
do this. I don't have another "Application" class in my namespace or
solution. Another mystery of life ;-)


Matt Berther said:
Hello ShadowMan,

Perhaps you've created another class in the same namespace called
Application.

Try modifying your line to read:
System.Windows.Forms.Application.Run(Global.MainForm);

--
Matt Berther
http://www.mattberther.com

I am getting an "'Application' is an ambiguous reference" error when I
try to start my WinForms appllication. How can the Application object
be ambiguous? Any ideas what I did wrong? Thanks.

I am using C# and VS2003.
I have declared references:
using System;
using System.Windows.Forms;
using System.ComponentModel;
The error occurs in:

[STAThread]
public static void Main()
{
try
{
Global.MainForm = new frmMain();
Application.Run(Global.MainForm); <========
'Application' is
an ambiguous reference
SetupSplashScreen();
GetConfigurationData();
if(ValidDB)
{
InitializeObjects();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,
"MainForm",MessageBoxButtons.OK,
MessageBoxIcon.Stop);
}

}
 
Back
Top