I designed a regular DLL using C on Visual Studio 2005. However I need to use it at a C# program. How do I do that? I tried to add the DLL as a reference in the C# project and then got error messages that " it could not be added and to be sure that is a valid assembly or COM object". I also copied the resulting DLL to the source directory where I will need to use this DLL and tried to use :
1 2
[DllImport("ReadMagStripe.dll")];
publicstaticexternvoid Cancel(void);// that is my C function
But it still does not work. I will simply wrap my functions on a C# class but I need to use those C functions from my DLL. How do I get started? Thanks for the help!
[DllImport("mydll.dll")]
publicstaticexternint Myfunc(
[MarshalAs(UnmanagedType.LPTStr)] string lpDeviceName,
IntPtr hpDevice);
// this was in C declared as
DWORD WINAPI MyFunc (LPSTR lpDeviceName, HANDLE *hpDevice);
What is not working now is how to convert this HANDLE to something that .NET can understand as it is declared as: