G
greg.merideth
There's a utility application I have that generates Excel files for the
end users that 99% of the time works just fine.
The problem I've encountered is when placing a lot of data (and by a
lot I mean creating 90+ tabs and filling each worksheet with 4-5,000
values with misc formatting per sheet) an exception is thrown when I
attempt to release the worksheet using:
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlInvSheet);
The "giveaway" on this is that when testing, I will notice an excel.exe
staying in memory after the 4-5th Excel creation which is then followed
by a crash.
During the day, my app will create 20-30 spreadsheets using Excel while
encountering no issues. It's just "every now and then" that a rogue
excel.exe stays and then corrupts the next attempt.
So, is there a way to see if a Com object has not been cleared by the
GC and somehow force a second clearing or possibly warn the user to
exit, kill the rogue excel (for now at least) and start again?
After releasing the sheets, workbook and Excel App, I do a call to
GC.Collect() and from what I've experimented with I can't see anything
else I should be doing to prevent these rogue excel's.
end users that 99% of the time works just fine.
The problem I've encountered is when placing a lot of data (and by a
lot I mean creating 90+ tabs and filling each worksheet with 4-5,000
values with misc formatting per sheet) an exception is thrown when I
attempt to release the worksheet using:
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlInvSheet);
The "giveaway" on this is that when testing, I will notice an excel.exe
staying in memory after the 4-5th Excel creation which is then followed
by a crash.
During the day, my app will create 20-30 spreadsheets using Excel while
encountering no issues. It's just "every now and then" that a rogue
excel.exe stays and then corrupts the next attempt.
So, is there a way to see if a Com object has not been cleared by the
GC and somehow force a second clearing or possibly warn the user to
exit, kill the rogue excel (for now at least) and start again?
After releasing the sheets, workbook and Excel App, I do a call to
GC.Collect() and from what I've experimented with I can't see anything
else I should be doing to prevent these rogue excel's.