Properly disposing COM objects in your .NET code
Here at work, we are using a third party component where they provide a COM interface. We're using .NET code so we are using COM interop to use the COM object. Remember back in the VB6 days when you would set your objects to null when you're done with it? Well, so did someone else here, because that's what I saw. I'm going to show you an example using the Microsoft Excel Type Library. Here's some sample code that I wrote that will open up an Excel file and get the text value from a cell in the first worksheet. using System; using Microsoft.Office.Interop.Excel; internal class Program { #region Methods private static void Main( string [] args) { var app = new Application (); var books = app.Workbooks; var book = books.Open( @"C:\Temp\doc.xlsx" ); var sheets = book.Sheets; var sheet = sheets.Item[1] as Workshee