我正在读取远程xml文件以在HttpWebRequest.GetResponse()部分转换货币时收到以下错误。
我使用的方法TugberkUgurlu_CurConverter.ConverterClass.ConvertActionForTL()正在读取xml文件并获取货币值。
但突然间,我开始收到这些错误。我该怎样预防他们?谢谢!
System.Net.WebException:操作 生成时间:星期一,3月28日 2011年19:33:48 GMT
System.Net.WebException:操作 已经超时了 System.Net.HttpWebRequest.GetResponse() 在 System.Xml.XmlDownloadManager.GetNonFileStream(URI uri,ICredentials凭证) System.Xml.XmlDownloadManager.GetStream(URI uri,ICredentials凭证) System.Xml.XmlUrlResolver.GetEntity(URI absoluteUri,String role,Type ofObjectToReturn)at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(对象 xmlResolver)at System.Threading.CompressedStack.runTryCode(对象 userData)at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode 代码,CleanupCode backoutCode,Object userData)at System.Threading.CompressedStack.Run(CompressedStack compressedStack,ContextCallback 回调,对象状态)at System.Xml.XmlTextReaderImpl.OpenUrl() 在System.Xml.XmlTextReaderImpl.Read() 在 System.Xml.XmlLoader.Load(XmlDocument的 doc,XmlReader reader,Boolean 保留白色空间) System.Xml.XmlDocument.Load(的XmlReader 读者) TugberkUgurlu_CurConverter.ConverterClass.ConvertActionForTL(CurrencyForTLConvert SelectCurrency,Decimal YourPriceToConvert)
答案 0 :(得分:1)
我没有看到您链接的文件有任何问题,XMLSpy也没有。
您说它偶尔会出现问题,并且该文件包含货币转换值,这些值可能会经常更改。也许文件偶尔会坏?
也许您应该首先尝试将文件作为文本文件加载,然后将其保存到磁盘。然后从磁盘上的文件加载XmlDocument。这样,如果它失败了,你仍然会看到坏文件。