UnauthorizedAccessException问题是未处理错误

时间:2017-06-11 16:16:51

标签: c#

我一直收到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;
    }

0 个答案:

没有答案