3

I have a COM object which exports a function like this:

SetValue(Guid paramID, ref object paramValue);

For a specific Guid, I should pass paramValue as "VT_ARRAY | VT_INT" as said in the document. Indeed I should pass 4 integers which is 16 bytes in total (4x4). It's simple in C++ but I couldn't do it in C#. How can I pass VT_ARRAY from C# to COM?

I tried this:

object[] values = new int[4];
// set values[0]-[4] some numbers
comObj.SetValue(new Guid(Guid_str), ref values);

But it says: Cannot convert ref object[ ] parameter to ref object.

Also I tried to create a struct and pass it to the function but it causes runtime error. Maybe I couldn't define it correctly.

Malik Çelik
  • 302
  • 1
  • 13

0 Answers0