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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:48:51+00:00 2026-06-08T16:48:51+00:00

I have built a COM server DLL in C++ with ATL by using the

  • 0

I have built a COM server DLL in C++ with ATL by using the “ATL simple object” wizard. I followed Microsoft’s ATLDLLCOMServer example. Everything works well except for one thing: I do not receive COM events in VBScript. I do receive the events in C#. I had events working in VBScript in an earlier MFC-based implementation as ActiveX control.

My control is defined like this:

class ATL_NO_VTABLE CSetACLCOMServer :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CSetACLCOMServer, &CLSID_SetACLCOMServer>,
    public IConnectionPointContainerImpl<CSetACLCOMServer>,
    public CProxy_ISetACLCOMServerEvents<CSetACLCOMServer>,
    public IDispatchImpl<ISetACLCOMServer, &IID_ISetACLCOMServer, &LIBID_SetACLCOMLibrary, /*wMajor =*/ 1, /*wMinor =*/ 0>,
    public IProvideClassInfo2Impl<&CLSID_SetACLCOMServer, &DIID__ISetACLCOMServerEvents, &LIBID_SetACLCOMLibrary>   /* Required for event support in VBS */
{
public:

BEGIN_COM_MAP(CSetACLCOMServer)
    COM_INTERFACE_ENTRY(ISetACLCOMServer)
    COM_INTERFACE_ENTRY(IDispatch)
    COM_INTERFACE_ENTRY(IConnectionPointContainer)
   COM_INTERFACE_ENTRY(IProvideClassInfo)
   COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()

BEGIN_CONNECTION_POINT_MAP(CSetACLCOMServer)
    CONNECTION_POINT_ENTRY(__uuidof(_ISetACLCOMServerEvents))
END_CONNECTION_POINT_MAP()

[...]

In VBScript I use the COM object like this:

set objSetACL = WScript.CreateObject("SetACL.SetACL", "SetACL_")

' Catch and print messages from the SetACL COM server which are passed (fired) as events.
' The name postfix of this function (MessageEvent) must be identical to the event name 
' as defined by SetACL.
' The prefix (SetACL_) can be set freely in the call to WScript.CreateObject
sub SetACL_MessageEvent (Message)
    WScript.Echo Message
end sub

The relevant parts of the IDL look like this:

[
    object,
    uuid(E1B57CA5-FD7F-4304-BC0A-8BEBDE231D53),
    dual,
    nonextensible,
    pointer_default(unique),
   helpstring("SetACL COM Interface")
]
interface ISetACLCOMServer : IDispatch
{
};

[
    uuid(00D4DCD3-02B9-4A71-AB61-2283504620C8),
    version(1.0),
   helpstring ("SetACL Type Library")
]
library SetACLCOMLibrary
{
    importlib("stdole2.tlb");

   [
        uuid(35F76182-7F52-4D6A-BD6E-1317345F98FB),
      helpstring ("SetACL Event Interface")
    ]
    dispinterface _ISetACLCOMServerEvents
    {
        properties:
        methods:
         [id(1), helpstring("Receives string messages that would appear on the screen in the command line version")]
         void MessageEvent([in] BSTR message);
   };

   [
        uuid(13379563-8F21-4579-8AC7-CBCD488735DB),
      helpstring ("SetACL COM Server"),
    ]
    coclass SetACLCOMServer
    {
        [default] interface ISetACLCOMServer;
        [default, source] dispinterface _ISetACLCOMServerEvents;
    };
};

The problem: SetACL_MessageEvent never gets called.

What I have tried:

  • After reading this KB article I added the implementation of IProvideClassInfo2, but that did not help.
  • This FAQ mentions that outgoing interface should not defined as a dual interfaces. I removed the “dual” from my interface definition, but that did not help.
  • I found this SO question that seems to describe a similar problem. An answer was never given, only a workaround.

UPDATE 1:

I know now where it is failing, but not why: in the fire event method in _ISetACLCOMServerEvents_CP.h the call to Invoke fails with E_UNEXPECTED. This is the line:

hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &params, NULL, NULL, NULL);

Solution:

The problem was that I called the event firing function from a background thread in the COM object, in other words from the wrong apartment.

  • 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-08T16:48:52+00:00Added an answer on June 8, 2026 at 4:48 pm

    Implementation of IProvideClassInfo2 should be sufficient (though I was under impression that it should work even without it). I created a minimalistic ATL project from template as a sample. This is ATL DLL + COM Class + a method and an event + IProvideClassInfo2:

    Source code [SVN, Browser Friendly] + Win32 Binary.

    Test .vbs is the following:

    Function Test_Event(Text)
      WScript.Echo "Event: " + Text
    End Function
    
    Dim Test
    Set Test = WScript.CreateObject("AlaxInfo.VbsEvents.Foo", "Test_")
    Test.Method("Event Fun")
    

    And the method itself is:

    // IFoo
        STDMETHOD(Method)(BSTR sText) throw()
        {
            ATLTRACE(atlTraceCOM, 4, _T("sText \"%s\"\n"), CString(sText));
            ATLVERIFY(SUCCEEDED(Fire_Event(sText)));
            return S_OK;
        }
    

    And having executed this, the output is:

    enter image description here

    I thought you might be having issues with events in your sample project if you are firing them from a background thread. You can also step your project with debugger and check if you have any errors in the Fire_ call.

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

Sidebar

Related Questions

I have built a simple menu in jQuery http://vanquish.websitewelcome.com/~toberua/ Here is a sample of
I am developing a website using Microsoft MVC3, and have built it upon the
Using Visual Studio 2010 and .NET framework 4.0 I have built a simple HelloWorld
I have built the Boost library from these instructions: http://stackoverflow.com/questions/3529163/install-boost-library-in-visual-c-2008 Directory of the unzipped
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
I have to build OEM versions of a COM library (DLL). Does anyone know
I have a very simple question. In FB tutorial https://developers.facebook.com/docs/mobile/ios/build/ it starts to login
I am using http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/portal/portal.html to build a portal. Obviously, i have custom windows inside
I'm have an issue with running the built in Python server that comes with
I've setup _NT_SYMBOL_PATH and have pointed it to srv*c:\symbols*http://msdl.microsoft.com/download/symbols When starting the debugger, I

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.