I am trying to call an unmanaged DLL within c#. I have the DLLs source so I know what the variables are within C, I just can't seem to build the DLLImport function correctly. Can someone help me out here
The C function
int UULoadFile (char *filename, char *fileid, int delflag)
{
.......
}
The C export
#define _ANSI_ARGS_(c) c
int UULoadFile _ANSI_ARGS_((char *, char *, int));
My DLLImport
internal const String UUDEVIEW = "uudeview.dll";
[DllImport(UUDEVIEW, EntryPoint = "UULoadFile", SetLastError = true)]
internal static extern int UULoadFile([MarshalAs(UnmanagedType.LPStr)]string filename, [MarshalAs(UnmanagedType.LPStr)]string fileid, int delflag);
Everytime I call UULoadFile I get,
An unhandled exception of type 'System.AccessViolationException' occurred in NZB Queue.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.