18

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?

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
Cheeso
  • 189,189
  • 101
  • 473
  • 713

1 Answers1

14

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
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • I could probably do this pretty simply with .NET 4.0 an the DLR magic, eh? – Cheeso Sep 08 '09 at 19:43
  • @Cheeso, not really. Based on your problem statement it appears you are trying to find a solution to call from native -> managed code. The DLR would only help a scenario where you were starting in managed code. – JaredPar Sep 08 '09 at 19:47
  • ah, I have to learn more about it. I thought there was some magic Javascript-to-CLR integration coming. – Cheeso Sep 08 '09 at 20:10