次のエラーが発生します。
Error 1 Reference to a non-shared member requires an object reference.
(on WindowsIdentity.Groups)
これは、 WindowsIdentity.Groupsプロパティを使用して、現在のユーザーが属するグループのID参照を表示するコードです。このコードは、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.