Question: I have a `dynamic` COM object as a private field in my class. I'm not sure whether it is considered managed resource (GC cleans it up), or not.

```
private dynamic _comConnector = null;

```

...

```
_comConnector = Activator.CreateInstance(Type.GetTypeFromProgID("SomeProgId"));

```

When implementing IDispose, should I clean it up as a managed resource (only when Dispose() is called explicitly), or as a native resource (when Dispose(false) is called from the finalizer too)?

```
private void Dispose(bool disposing)
{
    if (disposing)
    {
        // Free managed resources //

        // --> Should I call Marshal.FinalReleaseComObject(_comConnector) here?
    }

    // Free unmanaged resources //

    // --> Or maybe here?
}

```

Answer: 
It's a managed resource (basically a Runtime Callable Wrapper) and you should clean it up as such. [MSDN states that](http://msdn.microsoft.com/en-us/library/8bwh56xe.aspx):

> 
> Each RCW maintains a cache of interface pointers on the COM object it wraps and releases its reference on the COM object when the RCW is no longer needed. The runtime performs garbage collection on the RCW.
> 
> 
> 

I.e. the RCW is a managed resource that wraps the unmanaged COM references.

As an aside, releasing COM objects can be dangerous if you are using them from multiple threads in multiple places in your application, as described in [this blog post from Chris Brumme](http://blogs.msdn.com/b/cbrumme/archive/2003/04/16/51355.aspx).

If you are using a COM object in a scoped, single-threaded manner then you can safely call ReleaseComObject on that object when you are done with it: hopefully this is your case.
1 COM is a component so it all depends on what he does. if it fulfills the following functionalities

* Open files
* Open network connections
* Unmanaged memory
* In XNA: vertex buffers, index buffers, textures, etc.

=> So yes it's non managed ressource

Garbage Collector don't have informations about this ressource, so the clean is for user

2 For the clean, you can just use `Dispose` method (Or using bloc; who call dispose in the end of treatment).