Can P/Invoke call a native method of a native class?

  • Thread starter Thread starter blackbiscuit
  • Start date Start date
B

blackbiscuit

Dear all,

Suppose I have a native dll which contains a class having some public
methods. Can I call those methods by P/Invoke in C#?

Thank you very much!

Best,
Tony
 
Suppose I have a native dll which contains a class having some public
methods. Can I call those methods by P/Invoke in C#?

Yes, if those methods have been exported in the DLL.
 
Suppose I have a native dll which contains a class having some public
methods. Can I call those methods by P/Invoke in C#?

Yes, if those methods have been exported in the DLL.
 
Yes, if those methods have been exported in the DLL.

But how about their function names? Would you please give me an
example? Thank you very much!
 
Yes, if those methods have been exported in the DLL.

But how about their function names? Would you please give me an
example? Thank you very much!
 
But how about their function names? Would you please give me an
example? Thank you very much!

I can't give an example because I don't make native DLLs. But I'm sure there
has to be a way of controlling the exported name. You'd be better off asking
in a Win32 programming group, or maybe a C++ group.
 
But how about their function names? Would you please give me an
example? Thank you very much!

I can't give an example because I don't make native DLLs. But I'm sure there
has to be a way of controlling the exported name. You'd be better off asking
in a Win32 programming group, or maybe a C++ group.
 
blackbiscuit said:
Dear all,

Suppose I have a native dll which contains a class having some public
methods. Can I call those methods by P/Invoke in C#?

It would be very compiler specific. There is no standard calling convention
for C++ member functions. Also you will probably run into trouble because
C++ expects special member functions to be called, like copy constructors
and destructors, and you're going to have to be very careful to get the same
behavior out of P/Invoke.

I wouldn't recommend it.
 
blackbiscuit said:
Dear all,

Suppose I have a native dll which contains a class having some public
methods. Can I call those methods by P/Invoke in C#?

It would be very compiler specific. There is no standard calling convention
for C++ member functions. Also you will probably run into trouble because
C++ expects special member functions to be called, like copy constructors
and destructors, and you're going to have to be very careful to get the same
behavior out of P/Invoke.

I wouldn't recommend it.
 
It would be very compiler specific. There is no standard calling convention
for C++ member functions. Also you will probably run into trouble because
C++ expects special member functions to be called, like copy constructors
and destructors, and you're going to have to be very careful to get the same
behavior out of P/Invoke.

I wouldn't recommend it.

Hey guys,

Thank you very much! You are very helpful!

Best Wishes,
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top