Question Unable to Load DLL into .NET

bhagyeshwold

New member
Joined
Mar 20, 2010
Messages
1
Programming Experience
1-3
Hello Geeks,

I am developing a project that is dealing with CCTV camera made in china. I am provided by some DLLs from the company. Now i want to consume that dll into my application. I have tried default Visual studio's ADD REFERENCE features. then I have tried tlbimp.exe but it doesn't work.

here is the link of one of the dlls http://saltindia.org/camsearch.dll

I have search a lot about dll, some says "Check the dll header" and CLI Header. I opened this fine in notepad and I found only like "This will not work in DOS mode...". what to do next. Is there any way I can consume this file in .net.

I have already tried to add it as reference in Visual Studio 6.0 VB. even it says this is not a valis library.

Still dumpbin.exe is listing the function inside that dll.

I am confused about this scenario. Please guide me what to do with thi.

Thanks in advance
 
A .NET app can only reference other .NET assemblies or COM components. If your DLL isn't one of those then you can't reference it. Most likely your DLL exports functions directly. In which case you must use platform invoke to call them.

PInvoke is the technique used to call Windows API functions. You need to declare a proxy method that has a signature that's compatible with that of the unmanaged function you want to invoke. You then apply the DllImport attribute to the method to tell managed code where to find the unmanaged function and how to call it. You then call your proxy method in exactly the same way as you do any other managed method.

You can find plenty more information on PInvoke on the web. Most examples will relate to the Windows API, but the principles are exactly the same regardless. Just note that your unmanaged DLL must be in either the same folder as the assembly calling its function(s) or else the system32 folder.
 
Back
Top