Visual Studio导致蓝屏,PROCCESS_HAS_LOCKED_PAGES

时间:2016-07-07 14:09:01

标签: c# visual-studio-2015 webclient

在visual studio 2015 update 3中,我创建了一个winforms应用程序,并添加了一个执行WebClient修改版本的按钮。

触发按钮后,代码会一直运行到return base.DownloadString(url);它处于冻结状态,直到我通过shift + f5手动终止调试器。这导致包含消息PROCCESS_HAS_LOCKED_PAGES的BSOD。

我发现一条帖子告诉我要添加一个注册表项以获取更具描述性的消息,这对我来说也没有任何帮助。

还有另一种方法可以追踪造成这种BSOD的原因吗?

// code called in button
using (ProxyClient px = new ProxyClient(settings))
{
    px.BypassValidation = true;
    string a = px.DownloadString("http://tempuri.org");
}

ProxyClient如下所示

public class ProxyClient : WebClient
{
    internal ProxyClient()
    {
    }

    public ProxyClient(ProxySettings settings)
        : this()
    {
        _proxySettings = settings;
        GetProxy(settings);
    }

    private bool IsUsingProxy()
    {
        try
        {
            string response = this.DownloadString("http://icanhazip.com");
            response = response.Trim();
            if (string.IsNullOrWhiteSpace(response) || Settings.Ip == response)
            {
                return false;
            }
            return true;
        }
        // Some proxies are actively rejected, due to bad IP reputation.
        // If the rejection IP is not our IP, proxy is working properly.
        catch (WebException wex)
        {
            var wexMes = wex.InnerException == null ? string.Empty : wex.InnerException.Message;

            wexMes = wexMes.Substring(wexMes.LastIndexOf(' ') + 1, wexMes.LastIndexOf(':') - (wexMes.LastIndexOf(' ') + 1));

            if (wexMes != Settings.Ip)
            {
                return true;
            }
        }
        return false;
    }
    int bussyCounter = 0;
    new public string DownloadString(string address)
    {
        Uri url = default(Uri);

        while (base.IsBusy && bussyCounter < 30){
            bussyCounter++;
            System.Threading.Thread.Sleep(100);
        }

        if(bussyCounter >= 30)
           throw new TimeoutException("Client is bussy, timed out");

        url = new Uri(address);
        return base.DownloadString(url);
    }

    private static bool CanPing(string address)
    {
        Ping ping = new Ping();

        try
        {
            PingReply reply = ping.Send(address, 2000);

            if (reply == null)
                return false;

            return (reply.Status == IPStatus.Success);
        }
        catch (PingException)
        {
            return false;
        }
    }

    private bool GetProxy(ProxySettings settings)
    {
        string proxies = default(string);

        // Query that fetches 500 proxies in format "ip:port:anonimity:type;" as 1 big string

        var splitProxies = proxies.Split(';');

        foreach (var proxy in splitProxies)
        {
            var splitProx = proxy.Split(':');

            if (_blackListIps.ContainsKey(splitProx[0]))
                continue;

            if (!CanPing(splitProx[0]))
                continue;

            Proxy prox = new Proxy();

            prox.Ip = splitProx[0];
            prox.Port = Convert.ToInt32(splitProx[1]);
            prox.Https = settings.RequireHttps;
            prox.Ssl = settings.RequireHttps;
            prox.AnonimityLevel = (Anonymity)(Convert.ToInt32(splitProx[2]));
            prox.Type = (ProxyType)(Convert.ToInt32(splitProx[3]));
            ClientProxy = prox;

            if (IsUsingProxy())
                return true;
        }

        return false;
    }

    public Proxy ClientProxy
    {
        get
        {
            return _clientProxy;
        }
        set
        {
            _clientProxy = value;
            WebProxy prox = new WebProxy(_clientProxy.Ip, ClientProxy.Port);
            prox.BypassProxyOnLocal = false;
            this.Proxy = prox;
        }
    }

    private Proxy _clientProxy { get; set; }

    private static ProxySettings _proxySettings { get; set; }
}

}

0 个答案:

没有答案