Cannot change .NET Target Framework version in VS 2015 C ++ project

As the name says, I want to change the version of the .NET Target Framework for my C ++ project. Am I trying to compile with the / clr command, which I think should enable it?

Here is a screenshot: enter image description here

I am trying to create a DLL for use in Unity, and I want to be able to choose the right structure.

I tried to change the information in the .vxproj file, but I can not find the correct tag, and when I add it myself, it causes errors.

EDIT:

this is code that contains methods that you can call in C # to use the C ++ code I wrote earlier. I just edited the .h file in the CLR Class library (so the .cpp file contains only the header, which should be fine, I think)

#pragma once #include "PortAudioManager.h" using namespace System; namespace PortAudioWrapper { public ref class PortAudioManaged { private: PortAudioManager* audioManager; public: PortAudioManaged() : audioManager(new PortAudioManager()) { } virtual ~PortAudioManaged() { this->!PortAudioManaged(); } // = Object.Finalize !PortAudioManaged() { delete audioManager; audioManager = nullptr; } void openStreamManaged() { audioManager->openStream(); } void stopStreamManaged() { audioManager->stopStream(); } }; } 
+5
source share
2 answers

You should be able to follow the manual at https://msdn.microsoft.com/en-us/library/ff770576.aspx

The .NET structure that you can target in C ++ depends on the selected toolbox. It may be easier for you to simply download the older version of VS, which supports the structure you want to work with.

In the project file, I just created a section as shown below:

 <PropertyGroup Label="Globals"> <ProjectGuid>{48ACEC98-3369-486F-9033-8C433D408570}</ProjectGuid> <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <Keyword>ManagedCProj</Keyword> <RootNamespace>ClassLibrary1</RootNamespace> <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> </PropertyGroup> 
+4
source

Using VS2015, I had to update the .Net target of the managed C ++ DLL from 3.5 to 4.5.1. In the settings "Configuration Properties - General" .Net version of the Target Framework Version "is grayed out, and the value field is not edited.

  • Open the file Name.vcxproj in notepad.
  • Go to: "<" PropertyGroup Label = "Globals" ""
  • Add: "<" TargetFrameworkVersion "" v4.5.1 "<" / TargetFrameworkVersion "
  • Save the updated project file and reload it in VSS2015.

NOTE. Remove the "" around the corner brackets. Then, when the project restarts in VS2015, you can see the .Net version specified in the settings. In my case, it was V4.5.1.

+2
source

Source: https://habr.com/ru/post/1234466/


All Articles