Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / March 2005

Tip: Looking for answers? Try searching our database.

QueryInterface for interface Excel._Application fail , Excel Autom

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kowshik - 23 Mar 2005 11:05 GMT
We are using Excel 11.0 library in one of my c# project. We instantiate the
excel objects in the c# code and creating excel file on the server side. The
code is working fine on the local machine but it is failing on the dev
machine with the following description. Both machines are having excel 2003
installed.

The QueryInterface for interface Excel._Application failed.

I am sending the the excel code to this mail which causes this problem. I am
confused why this problem occurs. Please reply me in details.

The code as follows:

Excel.Application exlApplication = null;
                       Excel.Workbooks exlWorkBooks = null;
                       Excel._Workbook exlWorkBook = null;

                       // Create the Excel application object
                       exlApplication = new Application();
                       exlWorkBooks = exlApplication.Workbooks;
                       
                       exlWorkBook =
exlWorkBooks.Open(strXMLPath,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
                       
exlWorkBook.SaveAs(strEXLPath,XlFileFormat.xlWorkbookNormal,Type.Missing,Type.Missing,Type.Missing,Type.Missing,XlSaveAsAccessMode.xlExclusive,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);

                       exlWorkBook.Close(null,null,null);
                       exlApplication.Workbooks.Close();
                       
                       exlApplication.Quit();

                       
System.Runtime.InteropServices.Marshal.ReleaseComObject (exlWorkBooks);
                       
System.Runtime.InteropServices.Marshal.ReleaseComObject (exlWorkBook);
                       
System.Runtime.InteropServices.Marshal.ReleaseComObject (exlApplication);
                               
                       exlWorkBook = null;
                       exlApplication = null;
                       exlWorkBooks = null;

Waiting for your response....

Thanks & Regards
Kowshik.

Signature

Thanks & Regards,
kowshik

Misha Shneerson - 28 Mar 2005 05:24 GMT
I have no idea why this code is failing on one machine but not on
another.
However, this code is somewhat suspicious.
Why are you calling ReleaseComObject? Try to null out all the
references into Excel OM and calls GC.Collect();
GC.WaitForPendingFinalizers(); instead.

Also, can you run this code under debugger and tell which line of code
causes an exception?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.