Vista Parental Control Throwing Socket Exception?
I received a strange bug report the other day and was hoping that someone could help me figure out the culprit. I have a plugin that uses the Facebook API to make calls from a client program on the desktop. User reports that when Vista Parental Controls is enabled, he gets a runtime exception.
A detailed bug report is available here and I have verified that Vista Parental Controls is indeed the problem. Even if no site is blocked, and even if http://api.facebook.com
allowed, I still get the exception.
Below is the violation method. Specifically, the string string result = reader.ReadToEnd();
is where the exception is thrown.
private static XmlDocument ExecuteQuery(SortedDictionary<string, string> parameters,
string secretKey)
{
string query = GetQueryFromParameters(parameters, secretKey);
HttpWebResponse response = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(FACEBOOK_REST_URL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// Write the POST parameters to Facebook.
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(query);
writer.Close();
// Get a response.
response = request.GetResponse() as HttpWebResponse;
}
catch (WebException we)
{
// Getting the response must have thrown an HTTP error. We can still try to get the
// response from the caught exception though.
response = we.Response as HttpWebResponse;
}
if (response != null)
{
// Read the response.
StreamReader reader = new StreamReader(response.GetResponseStream());
string result = reader.ReadToEnd();
reader.Close();
response.Close();
XmlDocument responseXml = new XmlDocument();
responseXml.LoadXml(result);
return responseXml;
}
else
{
throw new FacebookException(Resources.FacebookResponseError);
}
}
Obviously I have to catch the IOException and not let it become an exception at runtime. Even so, the problem still persists. I spent some time on a google issue but didn't say anything about parental controls.
Any suggestions? Thank!