Я пытаюсь вызвать функцию P / Invoke C в C #, но всегда получаю System.AccessViolationException
.Пожалуйста, помогите мне понять, что я делаю не так?
C код:
RAYGUIDEF bool GuiListView(Rectangle bounds, const char *text, int *active, int *scrollIndex, bool editMode);
C # код:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct Rectangle
{
public float x;
public float y;
public float width;
public float height;
public Rectangle(float x, float y, float width, float height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
}
[DllImport(nativeLibName,CallingConvention = CallingConvention.Cdecl)]
public static extern bool GuiListView(Rectangle bounds, [MarshalAs(UnmanagedType.LPStr)]string text,[Out] int active, [Out] int scrollIndex, bool editMode);