LegacyWrapper icon indicating copy to clipboard operation
LegacyWrapper copied to clipboard

How to call a ref string function?

Open wdstest opened this issue 6 years ago • 0 comments

When the native signature is int MyFunction(BSTR * pszVerificationId)

With PInvoke I can do something like

[System.Runtime.InteropServices.DllImportAttribute("TestDLL", EntryPoint = "MyFunction", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
public static extern int MyFunction([MarshalAsAttribute(UnmanagedType.BStr)] ref string test);

With LegacyWrapper I don't know how to get it to work

[LegacyDllImport("TestDLL.dll")]
public interface IUser32Dll : IDisposable
{
	[LegacyDllMethod(CallingConvention = CallingConvention.StdCall)]
	int MyFunction([MarshalAs(UnmanagedType.BStr)]ref String test);
}

But when I call it with

using (var client = WrapperProxyFactory<IUser32Dll>.GetInstance(configuration))
{
	client.MyFunction(ref test);
}

I get System.Runtime.Serialization.SerializationException: 'End of Stream encountered before parsing was completed.'

wdstest avatar May 02 '19 03:05 wdstest