I have a COM type (created using tlbimp.exe ) and a C # class that wraps this object. I want to do some cleanup in the finalizer for my C # shell. Following the recommendations here , I could write something like this:
public class MyClass : IDisposable { private IMyComObject comObject; public MyClass() { comObject = new MyComObject(); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } ~MyClass() { Dispose(false); } protected virtual void Dispose(bool disposing) {
I know that finalizers can be executed in any order, so I should not try to use any object that the finalizer implements, however as far as I can tell, the created COM types created by tlbimp do not implement the finalizer, and therefore there should be higher OK
I could not find any official documentation about this, so my question is is it safe to reference and use COM objects in the finalizer?
source share