DllImport question for importing classes

R

Rookie

Hi,

Can DllImport be used to import a class from a C++ DLL into a C# project. If
yes, can someone provide links to tutorials, samples et al.

Hope to hear from someone, soon. Thank you.
 
M

Mattias Sjögren

Can DllImport be used to import a class from a C++ DLL into a C# project. If
yes, can someone provide links to tutorials, samples et al.

You may be able to call some of the class methods. This is
demonstrated in the file
Samples\Technologies\Interop\PlatformInvoke\Custom\CS\ClassMethods.cs
in the .NET SDK. But allocating and freeing instances of the class
must still be performed in native code. Generally a better solution is
to writea a managed C++ wrapper for the class.



Mattias
 

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

Top