Click here to Skip to main content
15,616,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to get data from database and move that data to an excel sheet and open new excel sheet and create pivot table and save to a network location using console .net 3.5 application.
Now the problem is when I try to create Excel object in my application I am getting the Error:"'Application' is ambiguous in the namespace 'Microsoft.Office.Interop.Excel'."
Please give me the solution for the above problem.
Updated 6-Sep-22 5:41am

Try modifying your statement and importing it

In C#
using Excel= Microsoft.Office.Interop.Excel

//Then in your code when you create the item
Excel.Application xlApp;

in VB
Imports Excel = Microsoft.Office.Interop.Excel

'Then in your code

Dim xlApp as Excel.Application
Share this answer
Alternatively, you could use a pragma:

#pragma warning disable 0467 //Suppress the ambiguity between methods warning
#pragma warning restore 0467
Share this answer
Ed Nutting 5-May-11 12:34pm    
Not a good solution at all. Do not supress error messages, solve them properly, otherwise they will just cause you more problems later. You may also then have lots of bugs that you don't know about which is only fine for personal use software, but even then it can be annoying.
Marc A. Brown 5-May-11 13:56pm    
Excellent point.
Ed Nutting 5-May-11 13:59pm    
Thank you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900