This question follows from my previous question: Create DLL from unmanaged C++, but you would not have to read it to understand this new question.
I now have a DLL that contains unmanaged C++ code consisting of a few functions, of which I only export one for outside use. Next, I need to use this DLL in a Managed C++ project (built with Common Language Runtime support). So far, I have added a reference to the existing unmanaged project's header file by setting the Additional Include Directories
in Visual Studio 2010.
If I now try to add a reference to the DLL file: MyManagedProject > Properties > Common Properties > Add New Reference > Browse > MyUnmanagedDLL.dll
, I get an error Could not add a reference to file MyUnmanagedDLL.dll because it is neither a .NET assembly nor a registered ActiveX control.
However, if I take the previously mentioned DLL and I copy it to the same folder as my Managed C++'s executable, everything works fine.
I am not sure if this is the correct way to do it, as it seems to be a hackish solution. Also, it means that I have to copy the DLL across every time I make a change to its source code.
To summarise my problem:
- I have created a DLL consisting of unmanaged C++ code, let's call it
MyUnmanagedDLL.dll
. I have also created a header file for this DLL. - I have a Managed C++ project (CLR), let's call it
MyManagedProject.vxproj
- How can I use
MyUnmanagedDLL.dll
inMyManagedProject.vxproj
? Is there a correct way to reference it, or should I just copy it to the same directory asMyManagedProject.exe
? (This works but I'm not sure if its good practise...)
Extra information: Windows 7, Visual Studio 2010 Ultimate, CMake 2.8.10.2