本文介绍了无法访问Disposed Object System.Net.Sockets.NetworkStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
FtpWebRequest req = (FtpWebRequest)WebRequest.Create(new Uri(FTPManifestFile));
req.Credentials = new NetworkCredential(uID, pswrd);
req.UseBinary = true;
req.Proxy = null;
req.KeepAlive = false;
req.UsePassive = false;
FtpWebResponse res = (FtpWebResponse)req.GetResponse();
Stream tmpStream = res.GetResponseStream();
TextReader tmpReader = new StreamReader(tmpStream);
XmlDocument newDoc = new XmlDocument();
newDoc.Load(tmpReader); // I AM GETTING EXCEPTION HERE
XmlNamespaceManager nsmgr1 = new XmlNamespaceManager(newDoc.NameTable);
nsmgr1.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1");
XmlNode node1 = newDoc.SelectSingleNode("/asmv1:assembly/asmv1:assemblyIdentity", nsmgr1);
它在 System.IO.StreamReader(tmpReader).EndOfStream
引发异常。 ..
推荐答案
TextReader tmpReader = new StreamReader(tmpStream);
string Reader= tmpReader.ReadToEnd();
XmlDocument newDoc = new XmlDocument();
newDoc.LoadXml(Reader);
这篇关于无法访问Disposed Object System.Net.Sockets.NetworkStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!