Results 1 to 15 of 15

Thread: ActiveX Export errors

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    ActiveX Export errors

    I'm trying to muddle my way through making this ActiveX. I'm using an ActiveX control (which I know works) to compare against any issues that arise.

    ---------------------

    I was receiving a number of duplicate linker errors caused by my imported lib file and MFC standard libraries.

    I set the option:

    Ignore All Default Libraries.

    I'm now ONLY getting link errors of:

    NAQX.def : error LNK2001: unresolved external symbol DllCanUnloadNow
    NAQX.def : error LNK2001: unresolved external symbol DllGetClassObject

    ----------------------

    When setting "Ignore All Default Libraries" in my ActiveX control,
    I get the same error even though no imported lib file is included.

    QUESTIONS:

    1. Besides MSDN is there any book that does a better explanation of what's going on behind the scene when you set the various linker options??

    2. If I leave the option "Ignore All Default Libraries" checked,
    is there a way to resolve the above LNK errors. BTW, the only place DllCanUnloadNow and DllGetClassObject show up is in the *.def file.


    Thanks
    David

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Every ActiveX control DLL is required to define these two functions. Are you sure you do?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    Thanks for responding Corned Bee:

    ----------------------
    Every ActiveX control DLL is required to define these two functions. Are you sure you do?
    -----------------------

    THis is where my confusion is coming in. In doing a Find all Files
    these only show up in the *.def file in both OCX's.

    So my assumption is they must be included in one of the default libraries since setting the linker option causes an error in both OCX's.

    So if I've shut off the link to the default library that contains these how do I:

    1. Define (assume you mean prototype here) them??
    2. In what class (or where) do I define them??
    3. Where do I get the prototype so I know how to define them??

    Thanks
    David

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    DllGetClassObject and DllCanUnloadNow are the essential interface your dll must provide in order to act as an ActiveX object. There's also DllRegisterServer, which is required if you want your DLL to work with regsvr32.

    1) A prototype is a declaration. You need to fully define them, i.e. give them a body.
    2) Globally.
    3) MSDN.

    If you're using ATL, that library should contain them already.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    Hi CornedBee:

    Thanks for sticking with me on this. Following are the steps I've used so far (***** identify step with result thereafter).

    ***** Step 1 -- Link Errors from Output Window

    Linking...
    TestLib.def : error LNK2001: unresolved external symbol DllCanUnloadNow
    TestLib.def : error LNK2001: unresolved external symbol DllGetClassObject
    Debug/TestLib.lib : fatal error LNK1120: 2 unresolved externals
    LINK : fatal error LNK1141: failure during build of exports file
    Error executing link.exe.

    TestLib.ocx - 4 error(s), 0 warning(s)
    -----------------

    ***** Step 2 - Search of code for one of the link errors


    Searching for 'DllGetClassObject'...
    D:\C mfc\Programs\TestActiveX\TestLib\TestLib.def(7): DllGetClassObject @2 PRIVATE
    Cannot open file 'D:\C mfc\Programs\TestActiveX\TestLib\TestLib.ncb'.
    D:\C mfc\Programs\TestActiveX\TestLib\TestLib.plg(63):TestLib.def : error LNK2001: unresolved external symbol DllGetClassObject
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\MSITOOL.MAK(142):ENTRY = $(ENTRY) /EXPORTllGetClassObject /EXPORTllCanUnloadNow /EXPORTllRegisterServer /EXPORTllUnregisterServer
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\OBJBASE.H(752):/* the server dlls must define their DllGetClassObject and DllCanUnloadNow
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\OBJBASE.H(769):STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppv);
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(26): String to be prepended on all the DllGetClassObject etc routines
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(27): in dlldata.c. This includes: DllGetClassObject, DllCanUnloadNow
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(423):NdrDllGetClassObject (
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(460):#define DLLGETCLASSOBJECT_ENTRY EXPANDED_ENTRY_PREFIX()##DllGetClassObject
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(584):#define DLLGETCLASSOBJECTROUTINE(pPFlist, pClsid,pFactory) \
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(585): HRESULT STDAPICALLTYPE DLLGETCLASSOBJECT_ENTRY ( \
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(591): NdrDllGetClassObject(rclsid,riid,ppv,pPFlist,pClsid,pFactory ); \
    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\RPCPROXY.H(639): DLLGETCLASSOBJECTROUTINE(pProxyFileList,pClsID,&gPFactory) \
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\AFXDISP.H(606): friend SCODE AFXAPI AfxDllGetClassObject(REFCLSID, REFIID, LPVOID*);
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\AFXDISP.H(607): friend SCODE STDAPICALLTYPE DllGetClassObject(REFCLSID, REFIID, LPVOID*);
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\AFXDISP.H(918):SCODE AFXAPI AfxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
    16 occurrence(s) have been found.

    ----------------
    ***** Step 3 - Except from MSDN based on above

    MSDN coGetClassObject

    To create and initialize embedded or linked OLE document objects, it is not necessary to call CoGetClassObject directly. Instead, call one of the OleCreate or OleCreateXxx helper functions. These functions encapsulate the entire object instantiation and initialization process, and call, among other functions, CoGetClassObject.

    ------------------
    ***** Step 4 - Except from MSDN based on Step 3

    MSDN OleCreate
    The OleCreate function creates a new embedded object,

    -------------
    ****** Step 5 - back to my code to see if OleCreate is handled

    Searching for 'OleCreate'...
    Cannot open file 'D:\C mfc\Programs\TestActiveX\TestLib\TestLib.ncb'.
    D:\C mfc\Programs\TestActiveX\TestLib\TestLibCtl.cpp(65):IMPLEMENT_OLECREATE_EX(CTestLibCtrl, "TESTLIB.TestLibCtrl.1",
    D:\C mfc\Programs\TestActiveX\TestLib\TestLibCtl.h(35): DECLARE_OLECREATE_EX(CTestLibCtrl) // Class factory and guid
    D:\C mfc\Programs\TestActiveX\TestLib\TestLibPpg.cpp(31):IMPLEMENT_OLECREATE_EX(CTestLibPropPage, "TESTLIB.TestLibPropPage.1",
    D:\C mfc\Programs\TestActiveX\TestLib\TestLibPpg.h(16): DECLARE_OLECREATE_EX(CTestLibPropPage)
    4 occurrence(s) have been found.


    ******* Step 6 - Implementation is here

    // TestLibCtl.cpp : Implementation of the CTestLibCtrl ActiveX Control class.

    // Initialize class factory and guid

    IMPLEMENT_OLECREATE_EX(CTestLibCtrl, "TESTLIB.TestLibCtrl.1",
    0x5d830368, 0x4fe2, 0x11d8, 0xa5, 0xa, 0x44, 0x45, 0x53, 0x54, 0, 0x1)

    ************************************************

    QUESTION: So if "no default libraries" killed OleCreate which in effect killed the EXPORT from within the def file, then how and where do I call it from within my program since this is the main cpp file???

    NEEDLESS TO SAY I"M LOST!!!!!!!!!!!!!!!!!!!

    David
    Last edited by dw85745; Jun 10th, 2004 at 02:44 PM.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Am I right in the assumption that you're using MFC to create the ActiveX control?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    Yes. It was suggested to go with MFC in lieu of ATL since I was including a lib file which was based on MFC 6.0.

    P.S. Don't have problem posting the code if you have the time to take a look see -- OR -- just create a simple generic MFC ActiveX with AppWizard, check the link option "No default Lib" and build.
    You'll get the same two errors I'm dealing with.

    It may be their is no workaround for "No default lib" and that I need to go back to my original link errors of "dups" between my lib and mfc42ud. Have tried just telling the linker to ignore ONLY "mfc42ud" but still generated the dup errors.
    Last edited by dw85745; Jun 10th, 2004 at 02:52 PM.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Hmmmmm...

    I don't know if the full code will help me any.

    Do you have these things in your code?
    IMPLEMENT_OLECREATE (maybe with _EX)
    IMPLEMENT_OLETYPELIB
    IMPLEMENT_OLDCTLTYPE
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    Have first two, not the last. Check both my control OCX and one I'm trying create and both do NOT have the last.

    // NAQXCtl.cpp : Implementation of the CNAQXCtrl ActiveX Control class.

    // ****** Bunch code

    // Initialize class factory and guid

    IMPLEMENT_OLECREATE_EX(CNAQXCtrl, "NAQX.NAQXCtrl.1",
    0xb68017e5, 0x527c, 0x11d8, 0xa5, 0xa, 0x44, 0x45, 0x53, 0x54, 0, 0x1)


    /////////////////////////////////////////////////////////////////////////////
    // Type library ID and version

    IMPLEMENT_OLETYPELIB(CNAQXCtrl, _tlid, _wVerMajor, _wVerMinor)

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Well, it's just something I copied out of an example...


    Can you do a search in files on the MFC source for the two functions?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    Corned Bee:

    Used my test OCX here as had a source browser file already created. As previously discussed problems the same with the linker option set.

    ****** Step 1 - My Search from Find in Files

    Searching for 'IMPLEMENT_OLECREATE'...
    Cannot open file 'D:\C mfc\Programs\TestActiveX\TestLib\TestLib.ncb'.
    D:\C mfc\Programs\TestActiveX\TestLib\TestLibCtl.cpp(65):IMPLEMENT_OLECREATE_EX(CTestLibCtrl, "TESTLIB.TestLibCtrl.1",
    D:\C mfc\Programs\TestActiveX\TestLib\TestLibPpg.cpp(31):IMPLEMENT_OLECREATE_EX(CTestLibPropPage, "TESTLIB.TestLibPropPage.1",
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\AFXCTL.H(286):#define IMPLEMENT_OLECREATE_EX(class_name, external_name, \
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\AFXCTL.H(682): // Class ID (implemented by IMPLEMENT_OLECREATE_EX macro)
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\AFXDISP.H(484):#define IMPLEMENT_OLECREATE(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
    5 occurrence(s) have been found.


    ******* Step2 - From AFXCTL.H

    #define DECLARE_OLECREATE_EX(class_name) \
    BEGIN_OLEFACTORY(class_name) \
    END_OLEFACTORY(class_name)

    #define IMPLEMENT_OLECREATE_EX(class_name, external_name, \
    l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
    const TCHAR _szProgID_##class_name[] = _T(external_name); \
    AFX_DATADEF class_name::class_name##Factory class_name::factory( \
    class_name::guid, RUNTIME_CLASS(class_name), FALSE, \
    _szProgID_##class_name); \
    const AFX_DATADEF GUID class_name::guid = \
    { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }; \
    HRESULT class_name::GetClassID(LPCLSID pclsid) \
    { *pclsid = guid; return NOERROR; }

    /////////////////////////////////////////////////////////////////////////////
    // Macros for type name and misc status

    #define DECLARE_OLECTLTYPE(class_name) \
    virtual UINT GetUserTypeNameID(); \
    virtual DWORD GetMiscStatus();

    #define IMPLEMENT_OLECTLTYPE(class_name, idsUserTypeName, dwOleMisc) \
    UINT class_name::GetUserTypeNameID() { return idsUserTypeName; } \
    DWORD class_name::GetMiscStatus() { return dwOleMisc; }


    ********* Step 3 From TestLibCtl.cpp

    /////////////////////////////////////////////////////////////////////////////
    // Initialize class factory and guid

    IMPLEMENT_OLECREATE_EX(CTestLibCtrl, "TESTLIB.TestLibCtrl.1",
    0x5d830368, 0x4fe2, 0x11d8, 0xa5, 0xa, 0x44, 0x45, 0x53, 0x54, 0, 0x1)


    /////////////////////////////////////////////////////////////////////////////
    // Type library ID and version

    IMPLEMENT_OLETYPELIB(CTestLibCtrl, _tlid, _wVerMajor, _wVerMinor)



    ******** Thats ALL folks

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Sorry for misleading you, I meant the Dll* functions.

    Come to think of it, I CAN do it myself...


    Hmm, they're there. Must be something with the project settings. Can't figure out what though.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    Hi Corned Bee:

    Didn't know what to make of your last post. Do you have any other suggestions??

    Thanks
    David

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Unhappy

    No, sorry.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    No apologizes necessary. Thanks for your time.

    Thought I'd try doing it with ATL instead of MFC this weekend and see what happens. If it works will post this thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width