I want to encapsulate the use of Excel Interop to make it easier to use somehow in a reuseable library.
So far, I have written some tests that work good altogether, except that between each test, I force Excel to quite so that it does have handle on the test file no more in order to be able to delete.
Once I quit the application instance between after each of my tests, Excel seems to be no longer responding, causing Windows to display
"Excel has stopped working and is looking for a solution"
message. This message lasts a few seconds, meanwhile Excel is closing, causing the hang on the file to occur and my tests to throw an exception like
"Cannot access file because it is being used by another process..."
message. Otherwise, each of my tests run individually just fine!
Any clue on how to solve this issue?
Do I overuse the
Quitting Excel only once the testing is through with my tests causes the files created for the tests purpose not to be deleteable.
If you've made changes to the
Workbook then could it be the "Do you wish to save changes?" dialog which is holding things up. You could try setting the
_Workbook.Saved property to
True prior to quitting the application. See here for details