If my C# program throws an error, I debug it. But sometimes if I debug, one of this two things are happening:
- My program is running fine when I debug it.
- My program doesn't throw an error, but it doesn't return what I want.
I'm using VS 2012 Express For Windows Desktop.
For example, I've this code:
void Form1_Load(object sender, EventArgs e)
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create("[URL TO ANY WEBSITE]");
hwr.Proxy = new WebProxy("22.214.171.124");
hwr.ProtocolVersion = HttpVersion.Version11;
HttpWebResponse resp = (HttpWebResponse)hwr.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
string s = sr.ReadToEnd();
richTextBox1.Text = s;
This throws an exception "Unable to connect to the remote server", because I don't have a proxy with 126.96.36.199 as IP. But if I debug, I don't get an error, just an empty rich text box.
What's the reason for this?
Thanks in advance.