C Library in a managed DLL

  • Thread starter Thread starter Kidan
  • Start date Start date
K

Kidan

I have a .LIB file, built an compiled in C that I need to use in
my .NET application.

If I build a C++.Net Console application and activate the exposed
functions directly the library works perfectly.

If I try to compile the .LIB file into a managed DLL for use in either
my VB.Net GUI or my managed C++.Net Console application I get a Null
Reference Exception when the LIB makes a MALLOC call.

Is there some command or option that I need to set to allow my managed
DLL to be able to run MALLOC?

Thanks!
 
Hi Kidan,

Have you tried to access the library via platform invoke instead of
importing it ?

something like this:

Declaration:
-------------

<DllImport("filename.(lib or dll)", EntryPoint:="YourREALFunctionName")> _
Private Shared Function YourAliasForyourfunction(parameter1 as
parametertype, etc.) As ReturnValueType
End Function--

Using it:
---------

VariableWithReturnType=YourAliasForyourfunction(parameters) ...


I hope this helps,

Roger
..NET 2005 and DB developer
 
Back
Top