简体   繁体   中英

How can I use ConfigurationPropertyAttribute in a .Net Core project targeting the net462 framework?

I'm trying to compile a small project, which was created with Visual Studio 2017 as a normal .Net project, using Visual Studio Code. One of the class, ConfigurationPropertyAttribute , cannot be found and I wonder which reference I should add to make it compile.

I tried searching for this class using reverse search in NuGet but it doesn't seem to exist.

Here is my .Net Core project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="microsoft.extensions.configuration" Version="1.1.2" />
  </ItemGroup>
</Project>

My ultimate goal is simply to be able to compile and debug an old project using Visual Studio Code instead of Visual Studio 2017 without necessarily using .Net Core as it is still lacking many features. I thought that by targeting net462 I would get access to everything from .Net 4.6.2 but it doesn't seem so. Did I miss something or is there something I didn't understand properly ?

Your .csproj file needs to add a Reference System.Configuration not a PackageRefrence Microsoft.Extensions.Configuration

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="System.Configuration" />
  </ItemGroup>

</Project>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM