Breakpoint loss

// break point set here>>
webRequest = (HttpWebRequest)WebRequest.Create(server);
webRequest.Timeout = 30000;
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.KeepAlive = false;


XmlDocument doc = new XmlDocument();
doc.AppendChild(request.ToXmlElement(doc));
byte[] data = XmlUtil.DocumentToBytes(doc);

webRequest.ContentLength = data.Length;

// write data to stream
requestStream = webRequest.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();

// get response
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

dataStream = response.GetResponseStream();

      

I set a breakpoint on the first line above, but for some reason I am losing it after webRequest = (HttpWebRequest) WebRequest.Create (server); exits and never hits any of the debug points in the next lines of this method. It's like it loses the site where it was in terms of debug points and ends up getting there later rather than continuing to remove the debug points I've added here, for example in the dataStream. I know this is not a bug because I eventually get a response. I want to look at the dataStream, but every time it exits to make a request, it never returns and the rest of the code goes outside of that method after receiving a response.

0


source to share


3 answers


I found that the response was returning to zero and another part of the code was executing, so the breakpoint never hit because it hit my error handling first and stopped there.



+1


source


I am a little unclear about your problem. Do you set a breakpoint on the comment line and it disappears from there? If so, can you put it on the next line, or insert a no-op line at the comment point and go from there? Setting a breakpoint on the comment line requires the debugger and language service to jump through a few extra hoops and increase the likelihood of the problem occurring (it should still work, but it's a good diagnostic test). Setting a breakpoint on the actual line of code should have no problem.



If you are setting the actual line of code, can you define "dissapear"? Does it go away completely or does it go blank or does it get a warning sign?

0


source


The first thing to check is to install Visual Studio in DEBUG mode, not RELEASE mode. In RELEASE mode, the compiler can optimize and reorder statements, and therefore the code in the source file does not necessarily match the line numbers stored for the breakpoint.

0


source







All Articles