2

Visual Studio 2019 v 16.11.2

I have a solution with two projects.

Project 1: is a c++ DLL
Project 2: is a c# Console App

Project 2 is using functions in the c++ DLL.

I have found that I have to copy the DLL into the same folder where the Console App exe lives. I see that this can be done automatically with a post-build command line in the DLL project options. Or the output folder can be set in the C++ app to place the DLL in the CSharp directory.

I have tried making the DLL project a dependency of the C# project, but this results in yellow triangles and no explanation of the yellow triangles.

enter image description here

I have also tried to add a reference by browsing to the location of the compiled DLL and selecting it, this results in the message:

`The reference is invalid or unsupported`

So two questions:

  1. How do I find out or see what those yellow triangles mean?
  2. Is copying the DLL manually (or automatically during a post-build script) the correct way of linking within the same solution?
Rowan Smith
  • 1,815
  • 15
  • 29
  • Is the C++ DLL standard C++ or C++/CLI? You can adjust the DLL output directory for your C+ DLL so that it will be created in the desired location. – Phil1970 Sep 08 '21 at 00:52
  • I am not sure how to determine this. I created the C++ project using the File -> New Project -> Dynamic Link Library (DLL). So you're saying that a third option would be to set the ouput directory to the "copy-to" location. That makes sense. – Rowan Smith Sep 08 '21 at 01:11
  • @Rowan Smith If it is not a C++/CLI dll, why do you need the reference in C# project? How are you planning to access the C++ code from C#? – FaisalM Sep 22 '21 at 03:04
  • @FaisalM How do I tell if it is a C++/CLI dll? Is this the reason why it needs to be coppied into the c# directory? I just used the C++ DLL project template in VS2019 to create it. – Rowan Smith Sep 22 '21 at 03:11
  • @Rowan Smith. "Add reference" option is for adding .NET dlls (C++/CLI project generates a .NET dll). Since you created a plain C++ dll, there is no point in adding the reference. You can adjust the C++project's output directory to get the dll created in the required folder. – FaisalM Sep 22 '21 at 03:30

0 Answers0