How to use a c++ class in a c# project?

  • Thread starter Thread starter Mads Jacobsen
  • Start date Start date
M

Mads Jacobsen

Hi,

I'm using VS.NET and I'm trying to use a c++ class in a c# project.

How can I use the c++ class - the code-completion doesn't 'read' the
functions and properties and won't even recognize that there is a class with
that name (the name of the c++ class). The two classes are in the same
namespace.

Do I miss something?

Mads
 
are you using managed c++ or unmanaged?
if your using managed, compile the class into a .NET DLL and it should
recognize it fine,
if it is unmanaged code, you can put it in a regular dll and use pInvoke to
access the methods.
 
Mads... Also, if it is an ATL dll, the compiler will wrap it for you
and you
can call it from C#.

http://support.microsoft.com/default.aspx?scid=kb;en-us;305990

Generate a primary interop assembly from Visual Studio .NET. To invoke
Tlbimp.exe to generate the interop assembly that you need, click Add
Reference on the Project menu, click the COM tab, and then select the
entry for the COM server.

Regards,
Jeff
 
Kovan said:
are you using managed c++ or unmanaged?
if your using managed, compile the class into a .NET DLL and it should
recognize it fine,
if it is unmanaged code, you can put it in a regular dll and use pInvoke to
access the methods.

Does it have to be a COM dll? Because I have a regular dll with no com
interface, I can't add reference from my project to it saying that it has
not COM interfance.

/m
 
Back
Top