【问题标题】:CS1069: The type name 'RegistryKey' could not be found in the namespaceCS1069:在命名空间中找不到类型名称“RegistryKey”
【发布时间】:2021-03-18 19:09:31
【问题描述】:

我使用 VS 2019 .NET Core 应用程序并遇到此类错误

CS1069:在命名空间“Microsoft.Win32”中找不到类型名称“RegistryKey”。此类型已转发到程序集 'Microsoft.Win32.Registry, version=4.1.3.0, Culture="neutral, PublicKeyToken=b03f5f711d50a3a' 考虑添加对该程序集的引用。

是什么原因造成的?

【问题讨论】:

    标签: c# .net visual-studio .net-core visual-studio-2019


    【解决方案1】:

    您是否安装了 NuGet 包 Microsoft.Win32.Registry

    “注册表”不是 .NET Core 的一部分。更多信息,您可以参考Use the Windows Compatibility Pack to port code to .NET Core

    【讨论】:

      【解决方案2】:

      好吧,正如消息本身所说,只需添加对该程序集的引用即可。将此添加到您的 .csproj:

      <ItemGroup>
        <PackageReference Include="Microsoft.Win32.Registry" Version="4.4.0" />
      </ItemGroup>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-03-25
        • 2017-07-12
        • 2011-05-13
        • 1970-01-01
        • 1970-01-01
        • 2023-02-22
        • 2012-06-19
        相关资源
        最近更新 更多