COM CleanUp when using IXSSO in .Net

I am using IXSSO to access Index Server similar to described in  article  Query Index Server with IXSSO in .NET” on  ASP101. (See also my post how to use Fill Dataset with rows in a specified range  http://thespoke.net/blogs/mnf/archive/2005/05/09/92495.aspx).


Recently I found a useful tip to dispose COM objects after the use. I noticed that  it is required to check for null before calling ReleaseComObject. So the finally section should be like this


finally

{

// recommended in http://www.eggheadcafe.com/forumarchives/inetserverindexserver/Aug2005/post23479438.asp

if (rs!=null)Marshal.ReleaseComObject(rs); //Recordset

if (query!=null)Marshal.ReleaseComObject(query); //Query

if (util!=null)Marshal.ReleaseComObject(util); //Utils

query = null;

util =

null;

rs=

null;

}


 

Advertisements