VB.NET-对非共享成员的错误引用需要对象引用(WindowsIdentity.Groups属性)

| 我收到以下错误:
   Error    1   Reference to a non-shared member requires an object reference.  
                (on WindowsIdentity.Groups)
这是我的代码,其中使用WindowsIdentity.Groups属性显示当前用户所属组的标识引用。此代码是为WindowsIdentity类提供的一个较大示例的一部分。
    Public ReadOnly Property Groups As IdentityReferenceCollection
    Get
        Dim irc As IdentityReferenceCollection
        Dim ir As IdentityReference

        irc = WindowsIdentity.Groups
        For Each ir In irc
            MsgBox(ir.Value)
        Next

    End Get
    End Property
我尝试通过以下方式解决此错误:
    Dim myWindowsIdentity As New WindowsIdentity
但出现以下错误:
    Error   2   Overload resolution failed because no accessible \'New\' accepts 
                this number of arguments.   
    
已邀请:
您必须具有该对象,或者必须创建一个新对象(已完成)。第二个错误是因为您没有为构造函数提供任何参数(新的)。如果您使用的是Visual Studio,则应具有智能感知功能。在“作为新的WindowsIdentity \”之后放置一个(,然后检查需要哪些参数。     

要回复问题请先登录注册