System.InvalidCastException: QueryInterface for interface Excel._Application failed.

Posted on 2006-04-19
Last Modified: 2007-12-19
This one has me stumped, hopefully not for much longer.  Here is the situation:  A .NET web application pulls data into a sql data reader , then creates, populates, and saves an Excel File.  This error is being thrown when the application runs on the server.  This error does not occur when it is in the debugger.  I even created a modified version of the program to run on my development box (release version) and ran it with no problems.  So it looks like the object cannot be created on the server Windows 2000 for some reason, here is the kicker: It has been working fine for about two years and suddenly broke.  Any ideas?

Thanks in advance-
Question by:ndegioia
    LVL 14

    Expert Comment

    Is Excel installed on the server?

    This is required for creating Excel files and are the Excel versions the same?
    LVL 4

    Author Comment

    Yes MS Office 2002 is installed on the server.  The applicaiton is using the Microsoft.Office.Core object Library 11.0.  The Execl version on my dev box is 2003.  Do you think the object library needs to be for 2002; possibly Microsoft.Office.Core object Library 10.0?  Is there a way it can work with both?

    LVL 14

    Accepted Solution

    That is definatly the problem. I would install Excel 2003 on the server to upgrade it and not downgrade your code to work with 2002.
    LVL 4

    Author Comment

    Thanks, I will give that a try.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Search console 3 44
    Problem to echo 6 32
    Select distinct 25 45
    Footer Widget in italics on one page only 2 17
    Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
    Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
    The viewer will learn how to dynamically set the form action using jQuery.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now