Discussion:
tlbimp problem
(too old to reply)
Gareth Lambert
2006-08-08 10:32:42 UTC
Permalink
Hi,
First of all, I am new to VB.net and programming in general. So my
apologies if I don't explain myself clearly.
I am trying to use a DLL within my code. It is not activeX so I can't
add it as a reference. I believe that I must run it through tlbimp.exe
and then declare it from my code. When I run it through tlbimp using the
line tlbimp MotoCom32.dll /out:Moto32.dll I get an error which is:
Tlbimp error : TI0000 : The input file ~MotoCom32.dll is not a valid
type library.
If I just declare the dll from within the code as per some books I've
looked at, I get a runtime error that the file is not present, even
though it is attached to the project.
This is driving me bonkers so any help will be fantastic.


*** Sent via Developersdex http://www.developersdex.com ***
c***@yahoo.co.uk
2006-08-16 16:49:52 UTC
Permalink
Tlbimp is only useful for importing DLLs that were written using
Microsoft's COM technology. The error you received suggests this is not
a COM DLL, but instead uses a Win32 style interface. For advice on how
to call the DLL, look up "Consuming unmanaged DLL functions" in MSDN.

An example declaration is:

using System.Runtime.InteropServices;

public class Win32 {
[DllImport("user32.dll", EntryPoint="MessageBoxA")]
public static extern int MsgBox(int hWnd, String text, String
caption,
uint type);

The "file not present" error may be connected to the location of the
dll. To test this, try copying the dll into the same location as your
executable - see if that makes a difference. The "file not present"
error could also be caused if the dll is found, but when it is loaded
it tries to reference a second library that is missing on your system.
Loading...