We're making use of MS Excel within a .NET C# application.
We have an issue whereby on closing the form / application which makes use of this - the instance of Excel is not cleared and still can be seen within 'Task Manager'.
private Excel.Application oXL;
private Excel.Workbook oWB;
private Excel.Worksheet oSheet;
We're making use of code like :
oXL = new Excel.ApplicationClass();
oWB = oXL.Workbooks.Add(xlStr);
oSheet = (Excel.Worksheet) sheets.get_Item(1);
On closing of the form we're using code such as :
if (oSheet != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet);
}
if (oWB != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWB);
}
if (oXL != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL);
}
However hard we try - we can't seem to get 'EXCEL.EXE' to be removed from the 'Task Manager'
Previously when we had a problem with MS Word we resolved it in a similar to above. This doesn't seem to work for EXCEL mind you.
Can anyone help us out with this one ?
Thanks in advance
Steve
We have an issue whereby on closing the form / application which makes use of this - the instance of Excel is not cleared and still can be seen within 'Task Manager'.
private Excel.Application oXL;
private Excel.Workbook oWB;
private Excel.Worksheet oSheet;
We're making use of code like :
oXL = new Excel.ApplicationClass();
oWB = oXL.Workbooks.Add(xlStr);
oSheet = (Excel.Worksheet) sheets.get_Item(1);
On closing of the form we're using code such as :
if (oSheet != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet);
}
if (oWB != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWB);
}
if (oXL != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL);
}
However hard we try - we can't seem to get 'EXCEL.EXE' to be removed from the 'Task Manager'
Previously when we had a problem with MS Word we resolved it in a similar to above. This doesn't seem to work for EXCEL mind you.
Can anyone help us out with this one ?
Thanks in advance
Steve