Requesting for anyones' kind help to solve a protracted problem, as described below.
I am generating XML files using C# (VS 2008). Environment is Windows Server 2003. There is no problem in generation of the XML files for any of the purposes unless when I use a specific Doctype like given below:
_fileHandler.FileHeader.Append("?xml version=\"1.0\" encoding=\"utf-8\"?");
_fileHandler.FileHeader.Append("!DOCTYPE tv SYSTEM \"xmltv.dtd\"");
_fileHandler.FileHeader.Append("tv");
(I have omitted '<>' from above 3 lines as otherwise the code was not getting displayed.)
If I remove the 2nd line above, i.e. the line with Doctype statement, files get successfully generated. It even gets successfully generated when run in Debug mode (also tested this in Prod environment). But the same code during run-time gives the error as given below:
Timestamp: 10/25/2010 4:08:50 PM : Message: EPGExporterLite.Client.FileDirector.BeginProduction
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenStream(Uri uri)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset(String systemId, String publicId)
at System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter.PushExternalSubset(String systemId, String publicId)
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.ParseInDocumentDtd(Boolean saveInternalSubset)
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.开发者_运维知识库DtdParserProxy.Parse(Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at EPGExporterLite.Model.FileBuilder.WriteAllContentToFile() in E:\EPGExporterLite\SourceFiles\EPGExporterLite_ServiceApp\EPGExporterLiteSvc\Model\FileBuilder.cs:line 249
at EPGExporterLite.Model.FileBuilder.Construct() in E:\EPGExporterLite\SourceFiles\EPGExporterLite_ServiceApp\EPGExporterLiteSvc\Model\FileBuilder.cs:line 120
at EPGExporterLite.Client.FileDirector.BeginProduction(FormatRequestInfo pRequestInfo, FormatResultInfo pResultInfo) in E:\EPGExporterLite\SourceFiles\EPGExporterLite_ServiceApp\EPGExporterLiteSvc\BusinessLayer\FileDirector.cs:line 59
Kindly do let me know if any further clarifications are required and kindly aid me in resolving this problem.
Thanks & regards,
Subhodip Sengupta1st Update to my Original Query
Adding further details of the code where the exception is occuring:
_fileHandler.XmlDoc = new XmlDocument();
_fileHandler.XmlDoc.LoadXml(_fileHandler.FileHeader.ToString() +
_fileHandler.FileContent.ToString() +
_fileHandler.FileFooter.ToString());
_fileHandler.XmlDoc.Save(_resultInfo.FileInfo.ToString());
_fileHandler.XmlDoc.Save(_resultInfo.FileInfo_Common.ToString());
As you can see, I am building the entire content in a stringbuilder object and then using the above code writing to the XMLDoc using LoadXML. I guess the problem is not in writing the file but reading it into the XmlDocument. To reiterate, this only happens when the DocType statement is added and not otherwise and that also only during run-time (no problems when I debug the service).
This code is part of a Windows Service. No exceptions are raised when I debug the service but only when the service is run.
If there are any more details that I can help you all with, kindly do let me know.
Thanks & regards,
Subhodip SenguptaYou'll get a much quicker response if you include your code that causes the exception and the exception details. Just a stack trace is nearly impossible to provide much help with.
My guess is that because you've used SYSTEM in your
If you don't want the XML parser to validate your xml, then don't include the
精彩评论