0

I am wondering when calling into native dll, what I can do using PInvoke is to call some static e method. Can I create unmanged object using PInvoke?

user496949
  • 83,087
  • 147
  • 309
  • 426
  • Please post some code illustrating an actual problem. Without knowing the context of your issue, we can really only guess at what you're asking, which isn't very clear in any case. – Bob G Feb 07 '12 at 00:10
  • The OP wants to create an unmanaged object using PInvoke and call its members. He is asking whether that is possible and how. – haiyyu Feb 07 '12 at 00:14

2 Answers2

0

What you could do is create a static function which creates a new instance of the object whose member functions you would like to call and returns a pointer to that to you. Then you would be able to pass the pointer to the wrapper functions, which would then operate on the object pointed to.

In short: It's not possible natively, but you can create a C wrapper.

haiyyu
  • 2,194
  • 6
  • 22
  • 34
0

With C++/CLI, you don't need to use PInvoke. Just do whatever C++ thing you want to do.

SamB
  • 9,039
  • 5
  • 49
  • 56