none
add dll reference to a managed c++ (mfc) visual studio 2008 project RRS feed

  • Question

  • Hi

    I tried the instructions in microsoft help site in http://support.microsoft.com/kb/310674
    but none of them are working.

    Adding the reference to visual c++ 2008 project property is ok and i included those "dll" or "tlb" references in the codes
    using "#include" or "#import", but i still can't see the com object in codes.

    So I tried to create interop assembly using tlbimp.exe tool, but i get "TlbImp : error TI0000 : The input file ... is not a valid type library."
    I appreciate any helps.

    - james


    jsk
    Friday, September 12, 2008 6:47 AM

All replies

  • It is quite unclear what you're talking about.  "Adding a reference to a project property" makes no sense.  You say in the title that it is a managed project but you can't use MFC in a managed project, nor expect #include or #import to work.  Also no mention of exactly what you're trying to reference or import.

    Taking a wild guess, you can generate a type library from a .NET assembly that's COM visible with the Regasm.exe /tlb command line option.  That .tlb can then be used in an #import directive to generate COM smart pointers for the interfaces.  Ask questions about how to use those smart pointers in the C++ General forum.

    Hans Passant.
    Friday, September 12, 2008 12:09 PM
    Moderator
  • Hi, Hans

    Thanks for your reply.
    Let me clarify in more details for you.
    If you see  http://support.microsoft.com/kb/310674 link, you will see there are several ways that make using references in a Managed C++ application.
    I tried all of them, but i still can not see the object of the dll reference project.
    "Adding a reference to a project property" means "Project references" part in above link.
    My project is a mixed mode project which contains normal C++ MFC classes and a managed C++ class which communicates with external dll objects.
    From my managed C++ class I am going to add the dll reference which contains many classes and objects from another project.
    I am able to register the dll file and create tlb file but with including those dll or tlb file in my manged C++ class i still cannot see
    the external objects.
    Then, i tried to create an interop assembly for a COM object, using the TLBIMP.exe tool, i get the following errors.
     tlbimp externalobj.dll /out:Interop.externalobj.dll
    "TlbImp : error TI0000 : The input file externalobj.dll is not a valid type library."

    Anybody had the same problems and solved it or knows what the problem is, please teach me.
    Thanks.
    - james

    jsk
    Sunday, September 14, 2008 3:19 AM