-1

I have a COM library I have imported into C# and it needs a function to be called with a ref variable and I'm unable to figure out how to declare a variable that the compiler will accept.

I have looked into the generated c# interface code and tried a collection of other declarations, none of which have worked.

The function I need to call is declared in the c# import file as

[DispId(1610809355)]
    [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
    bool brReadnext([MarshalAs(UnmanagedType.Struct), In, Out, Optional] ref object sItemId);

The same call was being used in Delphi as was declaring an OleVariant if that helps.

Just cant get it to be accepted by the compiler.

I have seen this post Marshaling Delphi 5 OleVariant to C# but it's not helped.

Andrew
  • 113
  • 2
  • 8

1 Answers1

0

I eventually found the solution.

I did have to declare it as an object, but I also had to assign a string to it, presumably to set its type. When I got the result, I could then assign it back to a string to get the value.

Andrew
  • 113
  • 2
  • 8