title: ActiveX COM in C#: how to bind C# events method to VBS sub
body: <p>Let us say I have a need to create an activex COM via C#. The reason to do so is that need to work with SDK, implemented in C# and provided by 3d party vendor. I have been following some great examples here in SO to create ActiveX COM with C# and load it via class id in .aspx. I also succeed calling the new COM method when someone clicks on a button from the web page.</p>
  
  <p>Now the problem is that, most of the new COM methods use async callback functions to wait for vendor response. For example in the new COM method hello(), there is a corresponding callback function, onHello(), which will be triggered when the COM dll receives response from vendor.</p>
  
  <p>My question is, how I can bind the onHello() function call with my web page VBS sub such as NewCOMID_onHello(), so that I can display something on the web page to notify user. I don't want to use busy-waiting to check infinitely.</p>
  
  <p>This is probably simple in C++ as we can try to map the call back function with VBS via .idl file etc, or BEGIN_CONNECTION_POINT_MAP, etc. But I am not sure how I can do so in .Net/C#. I've tried to use ComSourceInterfaces, but still no way to find out how to trigger the particular VBS sub when one of new COM method, such as onHello() is triggered by vendor response.</p>
  
  <p>Or, is that even doable? I know msft is abandoning Activex for Edge, but we cannot move away from activex for now.</p>
  
  <p>Thanks for any hint/help!!</p>
  
  <p><strong>Not a dup</strong> to <a href="https://stackoverflow.com/questions/61677/expose-an-event-handler-to-vbscript-users-of-my-com-object">Expose an event handler to VBScript users of my COM object</a> in that :1) COM server was in C++, not C#/.net 2) scripting not done in VBS</p>