Hi,
I'm having a problem using a COM component on C#; the component is developed in Delphi 5. I have this function:
This is the callable wrapper:
The error thrown from .NET is:
I changed WideString to PChar, and added a Marshal attribute on C#, and it worked. Still, I'm really hoping to fix this problem only on the .NET side. Can anyone shed a light on the probable cause of the error?
I'm having a problem using a COM component on C#; the component is developed in Delphi 5. I have this function:
Code:
[COLOR=green]// Delphi COM[/color]
function TestString(const strOMA: WideString): WideString; stdcall;
Code:
[PreserveSig]
string TestString([In, MarshalAs(UnmanagedType.BStr)]string StrOma);
I am expecting a debug string generated when TestString runs, but never happened (so the error might be during marshaling of parameters?). I also noticed that I only get the error when I have WideString as a parameter or as return type.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I changed WideString to PChar, and added a Marshal attribute on C#, and it worked. Still, I'm really hoping to fix this problem only on the .NET side. Can anyone shed a light on the probable cause of the error?