Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# with Excel 2003: Ambiguous reference error 1

Status
Not open for further replies.

MarkScripter

Programmer
Jul 26, 2001
9
US
I'm new to C# programming and am trying to write a simple application automating Excel 2003.

I have created a new Windows Application project named "WindowsApplication1" and used the default form name "Form1" and added a single command button to the form with no code. At this point (no code added) I can build it and display the form; however, as soon as I add a reference to Excel I get an "Ambiguous reference" error when I attempt to build.

The reference error is on the following line in the main routine below where it reads
'Application.Run(new Form1());:

static void Main()
{
Application.Run(new Form1());
}
I am assuming that the ambiguity occurs becuase the compiler does not know which application I am referring to (Excel or WindowsApplication1) but how do I correct the line to compile properly.

Thanks.

--Mark
 
The ambiguous reference is between System.Windows.Forms.Application and Excel.Application.

You must explicitly spec out the namespace:

System.Windows.Forms.Application.Run(new Form1());
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top