How to get a VC++/MFC ActiveX/COM object to run in classic ASP. RRS feed

  • Question

  • ======================== SOLVED ==========================
    The issue is that when making a COleControl derrived ActiveX control with Visual Studio 2005/2008 one must provide a member function IsInvokeAllowed and return TRUE.
    ======================== SOLVED ==========================

    How to get a VC++/MFC ActiveX/COM object to run in classic ASP.

    The OS is Windows Server 2008/IIS.

    I have made a VC++/MFC ActiveX control that I want to run from classic ASP's global.asa at application level as such:

    <object id=MyThing scope=application runat=server progid="My.Prog.Id"></object>
    ... More global.asa stuff...

    ~~~ Some classic.asp file~~~ language=javascript

    This always generates an "object error", with no details. So.. I have tried many things:

    1) Tried many different settings on the AfxOleRegisterControlClass.
       - Tried afxRegInsertable | afxRegFreeThreading - and afxRegApartmentThreading variations.

    2) Change the OLEMISC parameter to many variations.

    3) Ensure IISRESET is called in pre-build step to ensure COM object gets updated.

    4) Added logs to the constructor/destructor. Logs are getting written correctly.

    5) Added "Safe for Scritpting"...

    6) Made sure the Virtual Directory runs as an application. (Note logs still write before/after that change).

    7) I am the admin of the machine.

    That all said. Is there a direct sample to build a VC++ ActiveX control to run under global.asa at application scope int he manner I need?

    • Edited by ATS.NET Monday, July 27, 2009 7:01 PM
    Monday, July 27, 2009 5:14 PM


  • By default an MFC ActiveX does not allow automation until the ActiveX container (which you don't have) initialize it. You can try to override this behavior by overriding COleControl::IsInvokeAllowed and return TRUE.

    Please mark the post answered your question as the answer, and click the chartreuse pyramid floating over "Vote as helpful" to mark other helpful posts as helpful. This posting is provided "AS IS" with no warranties, and confers no rights.
    Visual C++ MVP
    • Marked as answer by Wesley Yao Monday, August 3, 2009 3:07 AM
    Monday, July 27, 2009 6:57 PM