Kim,
I've tried your resolution and other posts offering diiferent resolutions
unfortunately the EXCEL process remains present in Task Manager.
I've attached my code in hopes that it may shed some light on the issue.
As you can see the code is quite simple.....
My code is shown below:
Dim xlapp As Excel.Application
xlapp = CType(CreateObject("Excel.Application"), Excel.Application)
Dim wb As Excel.Workbook = xlapp.Workbooks.Open(fileName)
Dim xlSheet As Excel.Worksheet
Dim currRow As Integer
xlSheet = wb.Worksheets(1)
currRow = PTLRecordNumber
xlSheet.Cells(currRow, 1) = Me.LotNumber
xlSheet.Cells(currRow, 2) = Me.ScrewMachineNumber
xlSheet.Cells(currRow, 3) = Me.PartNumber
xlSheet.Cells(currRow, 4) = Me.PlatingDate
xlSheet.Cells(currRow, 5) = 0
xlSheet.Cells(currRow, 6) = Me.LoadSize
xlSheet.Cells(currRow, 7) = Me.FullLoad
xlSheet.Cells(currRow, 8) = Me.Mean
xlSheet.Cells(currRow, 9) = Me.Hi
xlSheet.Cells(currRow, 10) = Me.Low
xlSheet.Cells(currRow, 11) = Me.PLTankNumber
xlSheet.Cells(currRow, 12) = Me.BasketNumber
xlSheet.Cells(currRow, 13) = Me.CarrierNumber
xlSheet.Cells(currRow, 14) = Me.AdhesionTest
xlSheet.Cells(currRow, 15) = Me.SolderabilityTest
xlSheet.Cells(currRow, 16) = Me.OscilineNiTank
xlSheet.Cells(currRow, 17) = Me.Comments
'ss wb.SaveAs(fileName, Excel.XlFileFormat.xlExcel9795)
wb.Save()
wb.Close()
xlapp.Quit()
'ss xlApp.UserControl = True
'ss xlApp.Visible = True
'Attempt to close excel - notorious problem with .net not closing
all instances of Excel in task manager!!
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlSheet)
System.Runtime.InteropServices.Marshal.ReleaseComO bject(wb)
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlapp)
xlapp = Nothing
wb = Nothing
xlSheet = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
--
Thank You
"Kim Greenlee" wrote:
Alexey is correct. Every single Excel object that you created must be
released and nulled out. This includes all Worksheets, Ranges, etc... Please
see this MSDN article:
http://support.microsoft.com/default...;EN-US;q317109
I had a similar problem and found another reference that said to do the
garbage collection twice. This worked for me. Here is my C# shutdown code.
<pre>
private void ShutDownExcel() {
if (mExcelApp != null) {
mExcelApp.DisplayAlerts = true;
mExcelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComO bject(mExcelApp);
mExcelApp = null;
}
// Clean up memory so Excel can shut down.
GC.Collect();
GC.WaitForPendingFinalizers();
// The GC needs to be called twice in order to get the
// Finalizers called - the first time in, it simply makes
// a list of what is to be finalized, the second time in,
// it actually the finalizing. Only then will the
// object do its automatic ReleaseComObject.
GC.Collect();
GC.WaitForPendingFinalizers();
}
</pre>
Good luck,
Kim Greenlee
--
digipede - Many legs make light work.
Grid computing for the real world.
http://www.digipede.net
http://krgreenlee.blogspot.net