2011-01-27 3 views
1

사용자 지정 XML 문서를 작성하고 있습니다.XmlDocument.CreateDocumentType 메서드의 시간 제한

다음 코드는 실행하는 데 30 초 이상 걸립니다 (의견 참조). 이유는 무엇입니까?

System.Net.WebException:

"The underlying connection was closed: The connection was closed unexpectedly." 

Exception Stack Trace:

,369이 30 초 이상 걸리는 경우

var doc = new XmlDocument(); 
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null)); 

// hangs on next line - doc.CreateDocumentType() 
var xmlDocType = doc.CreateDocumentType(
      "svg" 
      , "-//W3C//DTD SVG 20001102//EN" 
      , "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd" 
      , null); 

doc.AppendChild(xmlDocType); 

, 나는 다음과 같은 예외를 얻을

at System.Net.HttpWebRequest.GetResponse() 
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) 
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) 
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) 
at System.Xml.XmlTextReaderImpl.OpenAndPush(Uri uri) 
at System.Xml.XmlTextReaderImpl.PushExternalEntityOrSubset(String publicId, String systemId, String 

답변

5

아마도 당신의 분석가가 www.w3.org에서 지정된 DTD를 가져 오려고하기 때문일 것입니다.

과도한 트래픽으로 인해 더 이상 DTD를 제공하지 않습니다 (정보는 this link 참조).

DTD를 W3C 웹 사이트에서 다운로드하여 로컬로 캐시하고 해결 프로그램에서 지정된 URL을 로컬 캐시 된 사본에 매핑해야합니다.