Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call a ref string function? #18

Open
wdstest opened this issue May 2, 2019 · 0 comments · May be fixed by #34
Open

How to call a ref string function? #18

wdstest opened this issue May 2, 2019 · 0 comments · May be fixed by #34

Comments

@wdstest
Copy link

wdstest commented May 2, 2019

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 wdstest changed the title How to call a c++ class static function? How to call a ref string function? May 3, 2019
@zalintyre zalintyre linked a pull request Oct 27, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant