我一直收到UnauthorizedAccessException的错误,我想知道是否有解决方法。
以下是错误来自的代码块。如果有人可以帮助我,我将非常感激。
public List<String> GetConnections()
{
dynamic everyConnection = null;
dynamic connectionProp = null;
List<string> connections = new List<string>();
everyConnections = netSharingManager.EnumEveryConnection; // <<< UnathorizedAccessException
foreach (dynamic connection in everyConnections)
{
everyConnection = netSharingManager.INetSharingConfigurationForINetConnection(connection);
connectionProp = netSharingManager.NetConnectionProps(connection);
connections.Add(connectionProp.Name);
}
return connections;
}