I'm having a C++ dll which has an exported function having the following signature...
__declspec(dllexport) __stdcall void Paint(LPDISPATCH& disp, VARIANT& x, VARIANT& y, VARIANT& z); I want to call the this exported function from C#.NET. For this is used the following prototype...
[DllImport("xyz.dll", CallingConvention = CallingConvention.StdCall) public static extern void Paint( [MarshalAs(UnmanagedType.IDispatch), In, Out] ref object which, [MarshalAs(UnmanagedType.I4), In, Out] ref object x, [MarshalAs(UnmanagedType.I4), In, Out] ref object y, [MarshalAs(UnmanagedType.I4), In, Out] ref object x); When i tried to invoke the call, it is throwing an exception saying that Attempted to read/write memory which is invalid.
Please advise me on this, on how to P/invoke this C++ API from .NET.
Much Thanks, Sundareswaran Senthilvel