Importing a DLL class (class exported from a VC++ DLL)

  • Thread starter Thread starter Rookie
  • Start date Start date
R

Rookie

Hi,

I have a DLL written in VC++ which exports a class. I want to import this
class into a C# application and be able to instantiate it in the C# code. Is
it possible to do this?

If yes, is it using StructLayout? If yes, even after defining the class in
my C# app. using StructLayout how do I actually link my code to the DLL? Are
there any other settings to be changed?

I hope to hear from someone out there ASAP. Code samples, links to
tutorials/articles et al. would be most helpful. Thanks a lot.
 
Rookie,

If the class is exposed through COM, then you can access it through .NET
(through the COM interop layer). However, if thi is just a regular C++
class, then you won't be able to do this. You will have to expose your
class through COM, or create a managed wrapper using Managed Extensions for
C++.

Hope this helps.
 
Back
Top