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 124539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:00:59+00:00 2026-05-11T05:00:59+00:00

recently I have been encountering problems with exposing events from .NET to COM. I

  • 0

recently I have been encountering problems with exposing events from .NET to COM.

I have been successful with this example (conceptually taken from http://blogs.msdn.com/andreww/archive/2008/10/13/exposing-events-from-managed-add-in-objects.aspx):

// The delegate type for our custom event.

[ComVisible(false)] public delegate void SomeEventHandler(object sender, EventArgs e);  // Outgoing (source/event) interface. [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IAddInEvents {     [DispId(1)]     void SomeEvent(object sender, EventArgs e); }  [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] [ComSourceInterfaces(typeof(IAddInEvents))] public class AddInUtilities : {            // Event field. This is what a COM client will hook up     // their sink to.     public event SomeEventHandler SomeEvent;      inernal void FireEvent(object sender, EventArgs e)     {         if (SomeEvent != null)         {             SomeEvent(sender, e);         }     } } 

This works fine, because the IAddInEvents interface is defined as IDispatch. However, I need to publish an event source interface which is IUnknown. I do not have control over the event interface as it comes from a third-party library (which will also be the consumer of the published events). Whenever I try to hook to the events, VB environment (where I am trying to sink the events) crashes, so does the VBA environment which the third-party product (ESRI ArcMap) uses.

I have been able to (partially) implement IConnectionPointContainer interface (which COM uses in the background to handle events) manually, then I am able to sink the event and step into my IConnectionPointContainer implementation. However, this seems like an overkill to me and I think that there must an implicit support for this in .NET. Second, with this approach I instantly lose the delegate support.

Does anyone have any experience with this? Thanks in advance.

  • 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. 2026-05-11T05:00:59+00:00Added an answer on May 11, 2026 at 5:00 am

    Ok, so I have been able to this by implementing the classic COM IConnectionPointCointainer, IConnectionPoint and IConnection (plus the enumeration interfaces). It does not integrate into the .NET delegate/event model, but works.

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

Sidebar

Ask A Question

Stats

  • Questions 154k
  • Answers 154k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The following regular expression returns C:\ in the first capture… May 12, 2026 at 10:31 am
  • Editorial Team
    Editorial Team added an answer Found the solution. Much simpler (but still a little hacky)… May 12, 2026 at 10:31 am
  • Editorial Team
    Editorial Team added an answer I don't know if you can do much better than… May 12, 2026 at 10:31 am

Related Questions

I've been encountering an OverflowException recently within GDI+ via a 3rd party tool which
I've been writing a lot recently about Parallel computing and programming and I do
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently I have been studying recursion; how to write it, analyze it, etc. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.