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

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:

I've set x64 target platform in the C# dll project:

Is there anything else I need to do?

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.
10,353 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 49,071 Reputation points

    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