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?
In the same way that a static variable exists before an object of the class is instantiated, a static method can be called before instantiating an object. So when a method doesn't need to access any stored values, a static method is appropriate.
In C#, static means something which cannot be instantiated. You cannot create an object of a static class and cannot access static members using an object.
A static method in Java (also called class method) is a method that belongs to the class and not the instance. Therefore, you can invoke the method through the class instead of creating an instance first and calling the method on that instance.
In C# it is not legal to access a static method or member variable through an instance, and trying to do so will generate a compiler error (C++ programmers, take note). Some languages distinguish between class methods and other (global) methods that are available outside the context of any class.
No you cannot do this. COM interop communicates via objects, not types.
Work arounds I know of ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With