简体   繁体   English

如何在针对net462框架的.Net Core项目中使用ConfigurationPropertyAttribute?

[英]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. 我正在尝试使用Visual Studio Code编译使用Visual Studio 2017作为普通.Net项目创建的小项目。 One of the class, ConfigurationPropertyAttribute , cannot be found and I wonder which reference I should add to make it compile. 找不到类之一ConfigurationPropertyAttribute ,我想知道应该添加哪个引用来进行编译。

I tried searching for this class using reverse search in NuGet but it doesn't seem to exist. 我尝试在NuGet中使用反向搜索来搜索此类,但它似乎不存在。

Here is my .Net Core project: 这是我的.Net Core项目:

<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. 我的最终目标只是能够使用Visual Studio Code而不是Visual Studio 2017编译和调试旧项目,而不必使用.Net Core,因为它仍然缺少许多功能。 I thought that by targeting net462 I would get access to everything from .Net 4.6.2 but it doesn't seem so. 我以为以net462为目标,我将可以访问.Net 4.6.2中的所有内容,但事实并非如此。 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 您的.csproj文件需要添加参考System.Configuration而不是PackageRefrence Microsoft.Extensions.Configuration

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

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

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

</Project>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从以net462为目标的SDK项目中引用System.Windows.Forms - How to reference System.Windows.Forms from a net462 targeting SDK project 将.NET Core应用重新定位为net462会错过断点 - Retargeting .NET Core app to net462 misses breakpoints 面向 .NET Standard 时,我到底可以在我的项目中使用 .NET Core 和 .NET Framework 中的哪些内容? - When targeting .NET Standard, what exactly can I use from .NET Core and .NET Framework in my project? 如何将 C# .net 框架项目更改为 .net 核心 3.0 项目? [等候接听] - How can I change a C# .net framework project to a .net core 3.0 project? [on hold] 如何在 .NET Core 项目中引用 .NET Framework 项目? - How do I reference a .NET Framework project in a .NET Core project? 将 Web 应用项目添加到我的解决方案中,并且解决方案中的其他项目已经使用 .net 框架,我可以将 .net 核心用于新项目吗? - adding a web app project to my solution, and the other projects in the solution already use .net framework, can I use .net core for the new project? 如何使用 Entity Framework Core 提高 as.net core 项目性能,升级我的 .NET 项目部分 - How can I faster aspnet core project performance with Entity Framework Core, Uptemize my .NET Project section 我的项目可以引用针对较低版本.net框架的程序集吗? - Can my project reference an assembly targeting a lower version of .net framework? 如何在.Net Framework 4.6.2应用程序中使用.Net核心类库(.NetStandard v1.5) - How can I use .Net Core Class Library (.NetStandard v1.5) into .Net Framework 4.6.2 Application 在Framework 4.6项目中使用.net核心DLL - Use .net core DLL in Framework 4.6 project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM