[英]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.