C #: How to call a method when forcing different sorting?

Invalid method declared in one of the Microsoft Primary Interop collections.

It is declared as:

void Write(object[] psarray);

which is incorrect and should actually be declared as:

void Write([In, MarshalAs(UnmanagedType.SafeArray)] object[] psarray);

I need to force the compiler to use [In, MarshalAs(UnmanagedType.SafeArray)]when calling the original method.

I don't mind doing something like:

object[] parameters = new Object[1];
parameters[0] = theStringIWantedToPass;

thing.GetType().InvokeMethod(
      "write", 
      BindingFlags.InvokeMethod,
      null,
      thing, 
      parameters);

But I need to know how to override InvokeMethod to use UnmanagedType.SafeArray sorting .

: "", , , , . , , , JMP-, .NET .


. , .

+3
1

PIA, .

, .

+2

Source: https://habr.com/ru/post/1702391/


All Articles