hello all you gurus. I am struggling with releasing com objects. I
have isolated the problem to the code below. Objects are released and
the process ends until I
use "int k = sheet.Count;" Then the process does not end. So I feel
confident the problem occurrs here. It appears another reference is
created that needs to be closed. Can anyone tell me how to do
this? :)
Thank you
Excel.Workbook workbook =
(Excel.Workbook )excelapplicati on.ActiveWorkbo ok;
Excel.Sheets sheet = workbook.Worksh eets;
// problem here
int k = sheet.Count;
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(work book);
workbook = null;
have isolated the problem to the code below. Objects are released and
the process ends until I
use "int k = sheet.Count;" Then the process does not end. So I feel
confident the problem occurrs here. It appears another reference is
created that needs to be closed. Can anyone tell me how to do
this? :)
Thank you
Excel.Workbook workbook =
(Excel.Workbook )excelapplicati on.ActiveWorkbo ok;
Excel.Sheets sheet = workbook.Worksh eets;
// problem here
int k = sheet.Count;
System.Runtime. InteropServices .Marshal.Releas eComObject(shee t);
sheet = null;
System.Runtime. InteropServices .Marshal.Releas eComObject(work book);
workbook = null;
Comment