Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ project reference in a C# project in visual studio 2008

Is is possible to reference a C++ project in a C# Project? I've tried adding a reference in the c# project to that C++ one but I get an error saying "A reference to could not be added"

like image 581
MBU Avatar asked Sep 02 '25 14:09

MBU


2 Answers

You cannot reference native DLLs directly. You could only if you compiled it for the CLI (targetting .NET CLR) or had build a COM component (in which case VS builds an interop DLL automatically). Otherwise no way, you would have to write a wrapper DLL.

like image 137
jdehaan Avatar answered Sep 05 '25 03:09

jdehaan


If your C++ project is a native (standard C++) project, then no. If it's a managed project, you can add a reference to it.

For native code, you'll need to use P/Invoke to access functions within the C++ DLL.

like image 40
Reed Copsey Avatar answered Sep 05 '25 05:09

Reed Copsey