Mixing net standard and visual c++

Flade, David 20 Reputation points


Using VS 2017, can one have both net standard 2.0 and visual c++ projects in the same solution with the net standard project referencing the visual c++ project (.vsxproj)?

If I create one solution containing two projects of this kind using VS 2017 (both projects are empty) and the net standard 2.0 project adds the visual c++ project using "Add->Reference->Projects-><file path to .vsxproj>" then compilation doesn't work with the following error:

"C:\Program Files\dotnet\sdk\2.1.526\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(129,5): error NETSDK1007: Cannot find project info for 'C:\Users<Me>\source\repos\ClassLibrary1\Project1\Project1.vcxproj'. This can indicate a missing project reference."



Microsoft Technologies based on the .NET software framework.
3,533 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,599 questions
{count} votes

Accepted answer
  1. RLWA32 42,001 Reputation points

    Now, in the same solution I want to create a third library which is a native C++ library using Visual C++ -> Empty Project (in the way I described it in my previous post) [name:UnmanagedLib]. UnmanagedLib shall be referenced from inside ClassLibrary2 (the C++/CLI one).

    The Empty project template defaults to creating a C++ console application.

    Clarify whether you intend to build a native C++ static library or intend to build a native C++ DLL and its related import library (.lib file).


    In my own test I found that eliminating the project reference from the C++/CLI project to either the project that creates a static library or a dll and instead setting the linker property page to add the appropriate path to "Additional Library Directories" and the .lib file names to "Additional Dependencies" solved the problem. The solution then built successfully within VS2017.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Hui Liu-MSFT 46,961 Reputation points Microsoft Vendor

    Hi,@Flade, David.

    . NET project reference does not support native C++.

    The operation of referencing C++ projects is problematic in itself. Even in Visual Studio 2022, it is not feasible.

    Building in Visual Studio 2022 is fine, but it will not reference C++ projects. There is a warning icon exclamation mark on the project.

    You could use C++ from C# via P/Invoke or C++/CLI.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


    Note: Please follow the steps in our documentation enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.