I would be using the 'using' keyword around all of my IDisposables first off. Secondly looks like you are leave the StreamReaders open.
Edit
To answer you comment about using keyword.
Instead of this:
Stream str = req.GetRequestStream();
str.Write(System.Text.Encoding.ASCII.GetBytes(lgRequest), 0, lgRequest.Length);
str.Close();
Write it this way:
using(Stream str = req.GetRequestStream())
{
str.Write(System.Text.Encoding.ASCII.GetBytes(lgRequest), 0, lgRequest.Length);
}
The using keyword will automatically handle all IDisplosable task for you.
I just noticed something your code and why I thought you weren't closing. You are calling close and then trying to ready the lines. This is a good example of why to get into the habit of using the 'using' keyword.
StreamReader reader = new StreamReader(res.GetResponseStream());
reader.Close(); //Calling CLOSE before trying to use the reader
string stringResponse = reader.ReadToEnd();
ANOTHER EDIT
public void logoutOfEM(string deviceName)
{
string lgRequest = "xml=<request>";
lgRequest += "<appInfo>";
lgRequest += "<appID>" + appID + "</appID>";
lgRequest += "<appCertificate>" + appCertificate + "</appCertificate>";
lgRequest += "</appInfo>";
lgRequest += "<logout>";
lgRequest += "<deviceName>";
lgRequest += deviceName;
lgRequest += "</deviceName>";
lgRequest += "</logout>";
lgRequest += "</request>";
using (Stream str = req.GetRequestStream())
{
str.Write(System.Text.Encoding.ASCII.GetBytes(lgRequest), 0, lgRequest.Length);
}
WebResponse res = req.GetResponse();
var response = string.Empty;
using(StreamReader reader = new StreamReader(res.GetResponseStream()))
{
response = reader.ReadToEnd();
}
}