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

  • SEARCH
  • Home
  • 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 7079453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:40:26+00:00 2026-05-28T06:40:26+00:00

I have defined new member in my class that is COMObject protected COMObject.Call call_

  • 0

I have defined new member in my class that is COMObject

protected COMObject.Call call_ = null;

This class has the following event handler that I subscribed to

call_.Destructed += new COMObject.DestructedEventHandler(CallDestructedEvent);

is using

Marshal.ReleaseComObject(call_) 

equals to

call_.Destructed -= new COMObject.DestructedEventHandler(CallDestructedEvent);
  • 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-05-28T06:40:27+00:00Added an answer on May 28, 2026 at 6:40 am

    Not at all. When you create a COM object, the object is created with the reference count of 1 on its RCW. When you subscribe to an event, the reference count is increased, because the object gets also referenced through its connection point container by a CCW, another wrapper for calls originating in the object back to your event handler.

    Marshal.ReleaseComObject() decreases the counter on the RCW by one, thus you declare no intent to call the object any more. But the object still can call your event handler. This is true even if you call Marshal.ReleaseComObject() multiple times (until it returns a 0), or call Marshal.FinalReleaseComObject(), which essentially releases the object until the reference count on the RCW decreases to 0. The RCW is released, and you cannot call the object any more, but the CCW is still around, so that it can still originate events.

    Now, even if you managed to release the object, that would not be safe anyway: what if the call on the event handler already in progress? That would result in the object being freed with its code in active stack. The behavior is undefined in this case.

    So, the safe way to release a COM object is to both unsubscribe carefully from all subscribed events and then call Marshal.FinalReleaseComObject() to release RCW, and, by way of doing that, the object itself. Even if you do that from inside the event handler, the COM object will not die immediately, as it presumably holds an additional reference on itself while in the call, if written correctly.

    See also:
    Runtime-Callable Wrappers
    COM-Callable Wrappers
    IConnectionPointContainer in the unmanaged world.

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

Sidebar

Related Questions

I have defined new member in my class protected COMObject.Call call_ = null; This
I have a class Date that I defined that models a date, it has
I have defined a class A and derived a new class B from A
I have a script which creates a user-defined object like this: obj = new
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
I'm trying to write a class that has a generic member variable but is
I have a user defined class that I want to create a public List
I have a Server class that upon accepted a TcpClient, raises an event whose
Is it OK to have a static member variable defined in a base class,
I have defined a new dialog and its controls in an already existing resource

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.