Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8046491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:48:10+00:00 2026-06-05T05:48:10+00:00

I am writing an application that opens Microsoft Excel through Interop. The problem I

  • 0

I am writing an application that opens Microsoft Excel through Interop.

The problem I am having is if the application itself Locks Up or Memory Leaks, my application becomes blocked and will not continue the thread.

I have a parent thread that looks at a directory and writes in a loop for each file

Convert(“src.xls”,”src.pdf”,null); And some times say for example if we give excel a file type it cannot open it will lock up. Which will lock my thread forcing me to have to kill the process.

public static class ExcelConverter
{
    public static bool Convert(string srcFile, string destinationFile, object[] parameters)
    {
        bool bStatus = false;
        Workbook excelWorkBook = null;
        Excel.Application application = null;

        try
        {


        application = new Excel.Application();
        object missingParam = Type.Missing;


            excelWorkBook = application.Workbooks.Open(srcFile);

            if (excelWorkBook != null)
            {
                excelWorkBook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, destinationFile);
            }
            bStatus = true;
        }
        catch (Exception)
        {

            bStatus = false;
        }
        finally
        {
            if (excelWorkBook != null)
            {
                excelWorkBook.Close(false);
                excelWorkBook = null;
            }

            if (application != null)
            {
                application.Quit();
                application = null;
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        return bStatus;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:48:12+00:00Added an answer on June 5, 2026 at 5:48 am

    for example if we give excel a file type it cannot open it will lock up

    It is probably trying to display a dialog that tells the user about it. Debug this by setting application.Visible = true so you can actually see the dialog. Fix it by specifying more arguments in the Open() call. The Password, Notify and CorruptLoad arguments have an effect. Screening the files better is an obvious workaround, Excel is really designed to be interactive and chatty about problems.

    You don’t have too much to fear from threads, Excel is a single-threaded COM object and COM makes sure that the interface methods are called in a thread-safe way. Which is does in your case by actually creating a new thread to give the interop object a safe home.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application that opens an existing .xlsx file and writes to certain
I'm writing an application that pulls values out of an Excel spreadsheet and then
I am writing an application that extracts images from an Excel spreadsheet using COM
I'm writing a small winforms application that opens several instances of another program. To
I am writing an application that needs pictures taken with the camera. The problem
Im writing an application that supposed to send coordinates in an SMS, but I've
I'm writing an application that will create difficult passwords for the user. The user
I'm writing an application that interacts with other processes on a x64 Vista machine.
I'm writing an application that utilizes JavaScript timeouts and intervals to update the page.
I am writing an application that is requiring me to do a DNS lookup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.