One solution (the.sln)
One C++ project (mycppproject.vcxproj in 2010or mycppproject.vcproj in 2008) which compiles a native DLL exporting some function(s). In debug this builds c:outputDebugmycppproject_d.dll and in release this builds c:outputReleasemycppproject.dll.
One C# console application (mycsharpconsole.csproj) containing PInvoke calls into the DLL.
All compiles fine.
When I build, I would like to be able to add a reference from the csharp project to the cpp DLL project so that it can copy the appropriate file from the appropriate directory into the inDebug directory the csharp project is built into.
This should be possible, since the IDE knows everything there is to know about where the DLL gets built, and where the C# application gets built.
In Visual Studio 2010:
I've tried "Dependencies..." on the csharp project and adding a dependency on mycppproject, but that has no effect.
I've tried "Add Reference..." on the csharp project and adding a reference to the cpp project, but I get a warning message 'The Target Framework version for the project "mycppproject" is higher than the current project Target Framework version. Would you like to add this reference to your project anyway?' (Yes/No/Cancel).
Clicking "Yes" produces the error message "A reference to mycppproject" could not be added."
question from:
https://stackoverflow.com/questions/5107694/how-do-i-add-a-reference-to-an-unmanaged-c-project-called-by-a-c-sharp-project 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…