System.Diagnostics.Process.Start(“http://google.com”) crashes IE

蓝咒 提交于 2020-01-06 16:50:47

问题


Okay I'm having a brain fart here. This should be simple, but I'm missing something.

I've got a win form and I'm trying to launch a web page when I click a button. The code for the button is here:

private void button2_Click(object sender, EventArgs e)
    {
        try
        {
            System.Diagnostics.Process.Start("http://www.google.com");
        }
        catch (Win32Exception ex)
        {
            Console.WriteLine(ex.Message);
            lblError.Text = ex.Message;
        }            
    }

When I run this on my computer, it works fine. On other computers, it only works if you have a browser already open. If you don't have a browser open, it opens the browser then just hangs. What gives?

I've also tried

`System.Diagnostics.Process.Start("IExplore.exe", "http://www.google.com");` 

ignoring the default browser (something I'd like to avoid but if it works, it works). I get the same result.

Thanks for your help.

EDIT: I'm also open to other methods of launching a web page with a button if any of you can think of one.


回答1:


There's probably a better way to do it but this works...

System.Diagnostics.Process.Start("cmd","/c start http://www.google.com");



回答2:


Okay, I got it working. I took Thinstall out of the equation and it magically works on every computer. Thanks guys for the help and suggestions.



来源:https://stackoverflow.com/questions/1209486/system-diagnostics-process-starthttp-google-com-crashes-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!