problem in adding reference to a DLL file

When trying to add a reference to a DLL  file (made with ANSI C++) to a VS2005 C# project, by right click on references, add reference, I receive the following error in both of them:
 
 "A reference to 'dllFileName.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
 
 
 
Now When I try to use the TlbImp on a .dll file the following error appears:
  "The input file 'dllFileName.dll' is not a valid type library".
 
How can I resolve this problem.


Answer this question

problem in adding reference to a DLL file

  • mostaf

    Using Platform invoke  to call any function, e.g.,'DeInitializeSearch',  within the .dll file produces the following error message:

    "Unable to find an entry point named 'DeInitializeSearch' in DLL 'SearchAuto1.dll'.".< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


  • malangpc

    Well to ask the obvious question, is that function actually exported by the Dll Is there a .DEF file naming the function in the build If it's exported with an export in the code, the name might be decorated (mangled) so it won't find it.

  • RuiDC

    The issue is whether this is really a COM Dll or not. You can add a reference if it really is a COM Dll that contains a type library. Many COM Dlls are built with the type library embedded inside them, and that's what it's looking for. Where did the Dll come from and is it really a COM Dll containing a type library There's a tool in the Windows SDK called OleView that can tell you.

  • Digital-Pioneer

    Thank you too much for your reply.

    When I use the OleView tool on the dll file I get the following message:

    "LoadTypeLib(myDllFile.dll ) failed. Error loading type library/DLL.

    TYPE_E_CANTLOADLIBRARY($80029C4A)".

    So, what can I do

    Thanks.

    Ayooya.

     

     


  • naryn

    It is likely that you have not created a COM component, so you will not be able to add a reference to it.

    If you have a DLL that exports some functions, then you can use platform invoke to call it - look it up in MSDN.


  • problem in adding reference to a DLL file