0

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

1
  • Part of the problem may be in how you are calling the method, can you show some code that attempts to call the method from .Net. Commented Mar 26, 2012 at 11:14

1 Answer 1

1

You have different return types, it is declared to return void, but you import it with bool.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah now it is corrected, please provide me an answer for my problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.