I have the following C function
NTSTATUS
SendBuffer(
_In_ UINT32 Number,
_In_ PWCHAR wszBuffer
)
and the following c# method
[DllImport(@"cfunc.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SendBuffer")]
public static extern long SendBuffer(uint Number, [MarshalAsAttribute(UnmanagedType.LPWStr)] string wszBuffer);
and in c# i try to call the function with
string buffer = "one two treee";
SendBuffer((uint)x, buffer);
But i receive an System.AccessViolationException
when i run the program. How can i fix this problem?
Thank you.