Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8542319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:02:05+00:00 2026-06-11T12:02:05+00:00

I have a dynamic COM object as a private field in my class. I’m

  • 0

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?
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:02:06+00:00Added an answer on June 11, 2026 at 12:02 pm

    It’s a managed resource (basically a Runtime Callable Wrapper) and you should clean it up as such. MSDN states that:

    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.

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I create a dynamic COM/OLE/ActiveX object in C# 4.0 from a program
I have the following code which creates a dynamic object that is assigned to
I have a Servlet class which do some dynamic class initialization and method invocation
I have an ATL COM object which needs to expose a collection of other
Embedded custom-tag in dynamic content (nested tag) not rendering. I have a page that
Microsoft shows how to create a dynamic class here: http://msdn.microsoft.com/en-us/library/system.reflection.emit.modulebuilder(v=vs.71).aspx This defines a custom
I have dynamic listview on my android client app that receive data from remote
I have dynamic web page with JS. There is a <textarea> and a Send
I have dynamic array filled with bytes, which are read from .raw file with
I have dynamic content in a div called txtresults like this: <div id=txtresults></div> This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.