i'm define in C# this interface for a COM-Server:
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("58C77969-0E7D-3778-9999-B7716E4E1111")]
public interface IMyInterface
{
string MyName { get; }
}
This interface is imported and implemented in a Delphi XE5 program.
The import looks like this:
IMyInterface = interface(IUnknown)
['{58C77969-0E7D-3778-9999-B7716E4E1111}']
function Get_MyName (out pRetVal: WideString): HResult; stdcall;
end;
The implementation like this:
type
TMyImpl = class(TInterfacedObject, IMyInterface)
public
function Get_MyName (out pRetVal: WideString): HResult; stdcall;
end;
function TMyImpl.Get_MyName (out pRetVal: WideString): HResult;
var
s: string;
begin
s:=''; // empty!
pRetVal:=s;
result:=S_OK;
end;
When i call that server from c# like this:
var server = new Server();
string s = server.MyName;
Then s is NULL and not an empty string as excepted.
How i can force that empty strings are transferred in COM as empty string and not replace by marshaling to NULL?