Prev: Gracefully closing a thread
Next: NetworkInformationException when calling GetAllNetworkInterfaces from a windows service
From: rizwanahmed24 on 21 Dec 2009 07:43 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 |