i have an old DLL written in VisualBasic and need to call the functions in C#. 14 of the 15 functions a already running (Tested with console project). The remaining function has a paramater PChar where i dont know how to call it in C#.
A working function looks like this:
[DllImport("C:\\DLL\\visualbasic.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern int command(out UInt32 pNumber);
public void Executecommand(out UInt32 pNumber, out int Res)
{
Res = command(out pNumber);
}
The not working function has two parameters: 1. out pData: PChar 2. const pDataLen (This is the length of data that is returned)
The manual for the VB DLL says that it is important to reserve memory before calling the function and also to free up memory after function is finished. 20 characters should be enough.
Can someone give me a hint how to call the function? When i simply use "string" then i get an exeception: An unhandled exception of Type System.AccesViolationException occured. Addidtional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Thanks for help.