I have the following IDL definition for a method in my native ATL COM project:
[id(1)] HRESULT Create([in] CHAR* a, [out] Details* b);
I have added a reference to my COM object from my C# project and it has generated the stub for this function for me, which I need to call:
void Create(ref sbyte a, out SampleNativeLib.Details b)
I would have expected the library to let me use a string as the ref sbyte a
parameter on this function.
How can I call the Create
method it has generated? Are there any alternatives to have it accept the ref sbyte a
parameter as a string instead?
You'll need to add the string attribute. This ensures that the CHAR
pointer is treated as a string:
[id(1)] HRESULT Create([in, string] CHAR* a, [out] Details* b);