Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

issue when using functions (having CString& type parameter) from C++ dll in to C#

3 views
Skip to first unread message

rizwan...@gmail.com

unread,
Dec 21, 2009, 7:43:26 AM12/21/09
to
Hi

i am trying to use some exported functions written in C++ dll in my C#
code
i have succeeded in importing the C++ dll, use some of its exported
functions, but here is one particular function that i am so far unable
to call from C#
the functions declaration in C++ dll goes like this:

int WINAPI Function1(CString& request, CString& response);

request is input parameter
response is output parameter, where i get the response from the
function.

Thats how i m declaring and using this function but it gives me error
"Attempted to read or write protected memory. This is often an
indication that other memory is corrupt".

Declaration:

[DllImport("C:\\Testing\\Mydll.dll")]
public static extern int Function1([MarshalAs
(UnmanagedType.LPStr)] string abc,
[MarshalAs(UnmanagedType.BStr)] out string output);

Call:
string output = "";
Function1(input, out output);


i think i am doing it completely wrong, help please...

//Rizwan

0 new messages