-1

我有以下代码来加载 XML

var ms = new GetXmlMemoryStreamFromSomewhere();
ms.Flush();
ms.Position = 0;

// Build the XmlDocument from the MemorySteam of (usually UTF-8) encoded bytes
xmlDocument.Load(ms);

我的流的字节大小为 27011。上面代码中的最后一行失败了System.Net.WebException Operation timed out

Watchforms.Position表示它4096没有读取超过 4096 个字节。

对此的任何指示将不胜感激。

4

1 回答 1

0

我的 XML在顶部有一个DOCTYPE 声明XmlDocument,并且Load 方法正在尝试下载 DOCTYPE 的 DTD,这花费了太长时间并且超时。

我将XmlResolver属性设置为 null,现在我的代码工作正常。

于 2018-08-13T15:28:31.380 回答