“<name>”不是“<classname>”的成员

已提供的成员不是类的成员。

错误 ID: BC30456

更正此错误

  1. 检查成员名称以确保其准确无误。

  2. 使用类的实际成员。

  3. 如果你尝试编译 SDK 样式的项目(带有以 <Project Sdk="Microsoft.NET.Sdk"> 行开头的 *.vbproj 文件的项目),并且错误消息涉及了 Microsoft.VisualBasic.dll 程序集中的类型或成员,请将你的应用程序配置为使用对 Visual Basic 运行时库的引用进行编译。 默认情况下,库的一个子集嵌入 SDK 样式项目中的程序集。

    例如,下面的示例无法编译,因为找不到 Microsoft.VisualBasic.Devices.ComputerInfo.InstalledUICulture 属性。 它不会嵌入到应用程序附带的 Visual Basic 运行时的子集中。

    Module Program
        Sub Main()
            Console.WriteLine($"Installed UI Culture: {My.Computer.Info.InstalledUICulture}")
        End Sub
    End Module
    ' Compilation produces the following output:
    '    c:\Projects\ComputerInfo\Program.vb(3,52): error BC30456: 'Computer' is not a member of 'bc30456.My'.
    '   [c:\Projects\ComputerInfo\bc30456.vbproj]
    

    若要解决此错误,请将 <VBRuntime>Default</VBRuntime> 元素添加到项目的 <PropertyGroup> 部分,如下面的 Visual Basic 项目文件所示。

    <Project Sdk="Microsoft.NET.Sdk">
      <ItemGroup>
        <Reference Include="Microsoft.VisualBasic" />
      </ItemGroup>
      <PropertyGroup>
        <VBRuntime>Default</VBRuntime>
        <OutputType>Exe</OutputType>
        <RootNamespace>bc30456</RootNamespace>
        <TargetFramework>net472</TargetFramework>
      </PropertyGroup>
    </Project>