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

  • SEARCH
  • Home
  • 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 855405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:04:12+00:00 2026-05-15T08:04:12+00:00

I use said invocation to release some Excel objects after I’m done. Is it

  • 0

I use said invocation to release some Excel objects after I’m done. Is it necessary to set references to null afterwards (like in the following code) ?

var dateCol = sheet1.get_Range("C4", "C" + rowOffset);
dateCol.NumberFormat = "Text";
Marshal.ReleaseComObject(dateCol);
dateCol = null;
  • 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-05-15T08:04:13+00:00Added an answer on May 15, 2026 at 8:04 am

    This is what I always use and it works very well

    using Excel = Microsoft.Office.Interop.Excel; 
    
        Excel.ApplicationClass _Excel; 
        Excel.Workbook WB; 
        Excel.Worksheet WS; 
    
    try 
        { 
    
        _Excel = new Microsoft.Office.Interop.Excel.ApplicationClass(); 
        WB = _Excel.Workbooks.Open("FILENAME", 
            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); 
    
            //do something 
    
        } 
        catch (Exception ex) 
        { 
            WB.Close(false, Type.Missing, Type.Missing); 
    
            throw; 
        } 
        finally 
        { 
            GC.Collect(); 
            GC.WaitForPendingFinalizers(); 
    
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(WB); 
    
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(_Excel); 
    
    
        } 
    

    Do a

    System.Runtime.InteropServices.Marshal.FinalReleaseComObject
    

    On all referenced Excel objects

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

Sidebar

Related Questions

In answer to this question , some people have said to use _Exit() and
Somebody said that when your PHP code and application use global variables then it
in this answer he said that i can use RIA services while creating my
On various places they said that you should use @ManagedProperty to get a request
I'm use Rails 2.2.2. Rails manual said, the way to extend controller from plug-in
I am trying (unsuccessfully) to use sp_send_dbmail (Transact-SQL) . The @recipients value is said
I am fairly new to JQuery. That being said I am trying to use
use C#,want to upload excel file on google doc. bellow syntax use to upload
Trying to create a new instance of the MortgageData object. Professor said to use:
My question is about generating invoices and receipts. The said bills use rates, names

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.