FYI, not sure if this will happen in production. But, we cannot get webRequest to work in a loop after several iterations. Our business requirement is to post/get sales data on an hourly (or some interval) keeping a local cache. Also, to check for version updates. We've scrapped SOAP and develop a lightweight set of calls because of the limited resources on these type of devices.
However, during on C# testing, this attached routine is called every minute and after a short period of time it causes the networking in the emulator to stop requiring a reboot. We've determined nothing from the logs other than it seems the DNS request dies as a reported error first and then additional request just timeout. But basically it is all over the place and not consistent. There also seems to be some chatter on this back a few months ago on bugzillia which discusses webrequests and making sure the dispose properly. However, that post still says they still have inconsistent issues. The question is, does anyone have a fixe for this? Or does it only happen in the emulator? This is a show stopper for us. private string getData(string url, Boolean postData, String xmlData) { String responseFromServer=string.Empty; try { // Create a request using a URL that can receive a post. WebRequest request = WebRequest.Create(url); { try { request.Timeout = 2000 * 60; //Two minutes if (postData) { // Set the Method property of the request to POST. request.Method = "POST"; // Create POST data and convert it to a byte array. byte[] byteArray = Encoding.ASCII.GetBytes(xmlData); // Set the ContentType property of the WebRequest. request.ContentType = "text/plain"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // Get the request stream. using (Stream dataStream = request.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); } } } catch { } // Get the response. using (WebResponse response = request.GetResponse()) { Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. using (Stream responseStream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(responseStream)) { responseFromServer = reader.ReadToEnd(); } } } } } catch (Exception ex) { System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(); String method = stackTrace.GetFrame(0).GetMethod().Name; log.writeLogInfo("ERROR " + method + ":", ex.Message + "\n" + ex.StackTrace.ToString()); } return responseFromServer; }
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid