I have a program that opens an Excel COM object, does some stuff, and closes it. Then I want to move that file after it\'s closed. This works fine if I run the program witho
For the record, I ran into this as well a few times. I found that this works when testing finalizers calling native side code in debug mode:
((Action)()=>{
// Do your stuff in here ...
})();
GC.Collect();
GC.WaitForPendingFinalizers();
The garbage collector seems to keep a copy of allocations rooted within the local method scope, so by creating a new method scope and exiting, the GC usually releases the resource. So far this works well for my debugging purposes.