How can I invoke a static method on a .NET object over COM interop?

前端 未结 1 1246
半阙折子戏
半阙折子戏 2020-12-11 15:12

Is it possible to invoke a static method on a .NET Object, via COM interop?

I know I could write a wrapper class. What if I don\'t wanna do that?

1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 15:23

    No you cannot do this. COM interop communicates via objects, not types.

    Work arounds I know of ...

    • The best work around is to create a wrapper method on an instance to do the call on the type. Yes this still requires an instance so it defeats the purpose but it's you're best option.
    • Reverse PInvoke: Still requires you to pass a function pointer down to the C++ layer

    0 讨论(0)
提交回复
热议问题