我收到以下错误:
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.