Cannot add C# .NET4.6.2 project as a reference of C++ project RRS feed

  • Question

  • Hi,

    Our company used to use VS2010 to build a C++ project that referenced a C# project that target .NET 4.0 framework.  Everything seems to work fine.

    Then we decided to move to VS2015 professional and latest .NET framework. Solution seems to be converted properly, however, when I tried to change the C# project to target .NET4.6.2, the C++ project that referenced it start to complain about cannot use any helper function from that C# reference.  Then I tried to remove and re-add the project, and I got the following error.

        One or more error occurred.

        A referenced to <project> cannot be added because it is incompatible with this project.

    The C++ project default using:

    Target Platform Version: 8.1

    Platform Toolset: Visual Studio 2015 (v140)

    I've changed Target Platform to 10.0.14393.0.  Problem still exist.

    Then I tried to change the C# project to target .NET 4.6 or 4.5, I still can't add the project to the C++ project until I change it back to .NET 4 then it allows me to add.

    Any help would be appreciated.



    Friday, February 3, 2017 4:58 PM

All replies

  • Hello,

    You should also change your C++\CLI project target version, for that unload It then right click on it and select "Edid ---.vcxproj" replace target framework to 4.6.1 save and reload project . Now try again add reference.

    Make the community better together

    • Proposed as answer by Kristin Xie Tuesday, February 14, 2017 2:43 AM
    • Edited by Azat Tazayan Tuesday, April 3, 2018 5:58 AM
    Friday, February 3, 2017 5:57 PM
  • Can you elaborate on how to fix this issue? I am having the same problem. If you do have the step by step process I would really appreciate it. Thanks
    Friday, November 2, 2018 3:19 AM
  • If cause is incorrect value for TargetFrameworkVersion tag, or tag is missing.

    More explicitly.

    Solution Explorer -> R/C c++ prj and unload. -> R/C c++ prj and edit vcxproj file.

    -> Find <PropertyGroup Label=Globals>

    If present, edit <TargetFrameworkVersion> to 4.7.1 or whatever.

    If not present, add <TargetFrameworkVersion>4.7.1</TargetFrameworkVersion>

    Save and exit. Reload c++ prj. If this was the cause, can now add c# prj to c++ prj as reference.

    Thursday, December 6, 2018 2:47 PM