How to set platform when I set .Net 5.0 C++/Cli dll project reference to .Net 5.0 C# dll project?

Ramon X 21 Reputation points
2021-02-09T15:10:59.197+00:00

I created a C++/Cli dll project (x64) and a C# dll project, both of whose platform were .Net 5.0.
In the C++/Cli project, when I set the reference to the C# project, a message box says this two project based on different platform:
65859-qq%E6%88%AA%E5%9B%BE20210209230340.png

I've set x64 target platform in the C# dll project:
65902-qq%E6%88%AA%E5%9B%BE20210209230502.png

Is there anything else I need to do?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,114 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 55,476 Reputation points
    2021-02-09T16:00:56.38+00:00

    To be clear the project page UI you posted is for adjusting the settings of each configuration/platform combination. The 2 dropdowns at the top don't impact what is being built. They determine what settings will be used when that particular configuration/platform is being built. You can flip through the possible combinations and adjust the settings as needed.

    To control what actually gets built you need to go to Configuration Manager on the solution. Right click the solution (in Solution Explorer) and select Configuration Manager. Within here is the list of all the solution configuration/platform combinations. It is the solution combinations that you are building, not the individual project combinations. This particular dialog allows you to specify that the solution's configuration/platform combinations then build the specific project configuration/platform configurations. For example you probably have a Debug/x86 solution configuration that is configured to build all the projects in the solution. For each project it will build the project's Debug/x86 configuration. The same thing for Release/x86. For .NET libraries generally you'll be using the Any CPU platform instead.

    So, to make sure your build is using the x64 version of your C# DLL then go to the Configuration Manager for the solution. Then go to the configuration/platform you are building for the solution (probably Debug/x64 and Release/x64). For each of these combinations change the C# project's platform to be x64 instead of AnyCPU. Then when you build your solution for debug/release it'll build the corresponding C# project for x64 as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.