microsoft / XmlNotepad

XML Notepad provides a simple intuitive User Interface for browsing and editing XML documents.
https://microsoft.github.io/XmlNotepad/
MIT License
989 stars 207 forks source link

Unhandled exception on XML file load of XML document known to accepted by target entity #371

Closed slundahl2 closed 6 months ago

slundahl2 commented 7 months ago

The unhandled exception below occurs in the XmlCache.cs method FireModelChanged() line: this.ModelChanged(this, new ModelChangedEventArgs(t, node));

It occurred while attempting to load the attached file which was successfully uploaded to CrossRef.org for DOI processing. (I have changed the user information in the XML file.)

I did not debug further to see what is null. I do know that the XML is valid and served its purpose. ValidXmlForXMLNotePadIssueSubmitted.txt

Error: System.ArgumentNullException HResult=0x80004003 Message=Value cannot be null. Parameter name: uriString Source=System StackTrace: at System.Uri..ctor(String uriString) at XmlNotepad.SchemaCache.Add(XmlSchema s) in D:\Projects\XmlNotepad\src\Model\SchemaCache.cs:line 259 at XmlNotepad.SchemaCache.AddImports(XmlSchema parent) in D:\Projects\XmlNotepad\src\Model\SchemaCache.cs:line 297 at XmlNotepad.SchemaCache.Add(XmlSchema s) in D:\Projects\XmlNotepad\src\Model\SchemaCache.cs:line 268 at XmlNotepad.SchemaCache.AddImports(XmlSchema parent) in D:\Projects\XmlNotepad\src\Model\SchemaCache.cs:line 297 at XmlNotepad.SchemaCache.Add(XmlSchema s) in D:\Projects\XmlNotepad\src\Model\SchemaCache.cs:line 268 at XmlNotepad.SchemaCache.AddImports(XmlSchema parent) in D:\Projects\XmlNotepad\src\Model\SchemaCache.cs:line 297 at XmlNotepad.SchemaCache.Add(XmlSchema s) in D:\Projects\XmlNotepad\src\Model\SchemaCache.cs:line 268 at XmlNotepad.Checker.ValidateContext(XmlCache xcache) in D:\Projects\XmlNotepad\src\Model\Checker.cs:line 91 at XmlNotepad.Checker.Validate(XmlCache xcache) in D:\Projects\XmlNotepad\src\Model\Checker.cs:line 130 at XmlNotepad.XmlCache.ValidateModel(ErrorHandler handler) in D:\Projects\XmlNotepad\src\Model\XmlCache.cs:line 103 at XmlNotepad.FormMain.OnModelChanged() in D:\Projects\XmlNotepad\src\Application\FormMain.cs:line 1504 at XmlNotepad.FormMain.OnModelChanged(Object sender, ModelChangedEventArgs e) in D:\Projects\XmlNotepad\src\Application\FormMain.cs:line 1497 at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at XmlNotepad.XmlCache.FireModelChanged(ModelChangeType t, XmlNode node) in D:\Projects\XmlNotepad\src\Model\XmlCache.cs:line 652 at XmlNotepad.XmlCache.Load(XmlReader reader, String fileName) in D:\Projects\XmlNotepad\src\Model\XmlCache.cs:line 219 at XmlNotepad.XmlCache.Load(String file) in D:\Projects\XmlNotepad\src\Model\XmlCache.cs:line 191 at XmlNotepad.FormMain.InternalOpen(FileEntity entity) in D:\Projects\XmlNotepad\src\Application\FormMain.cs:line 1088 at XmlNotepad.FormMain.d__93.MoveNext() in D:\Projects\XmlNotepad\src\Application\FormMain.cs:line 984

This exception was originally thrown at this call stack: [External Code] XmlNotepad.SchemaCache.Add(System.Xml.Schema.XmlSchema) in SchemaCache.cs XmlNotepad.SchemaCache.AddImports(System.Xml.Schema.XmlSchema) in SchemaCache.cs XmlNotepad.SchemaCache.Add(System.Xml.Schema.XmlSchema) in SchemaCache.cs XmlNotepad.SchemaCache.AddImports(System.Xml.Schema.XmlSchema) in SchemaCache.cs XmlNotepad.SchemaCache.Add(System.Xml.Schema.XmlSchema) in SchemaCache.cs XmlNotepad.SchemaCache.AddImports(System.Xml.Schema.XmlSchema) in SchemaCache.cs XmlNotepad.SchemaCache.Add(System.Xml.Schema.XmlSchema) in SchemaCache.cs XmlNotepad.Checker.ValidateContext(XmlNotepad.XmlCache) in Checker.cs XmlNotepad.Checker.Validate(XmlNotepad.XmlCache) in Checker.cs ... [Call Stack Truncated]

lovettchris commented 6 months ago

Great bug, thanks. I pushed some fixes which will be included in the next build, but I'm still seeing validation errors which may or may not be another problem, so I need you to check those errors and file a new bug if the schemaset is not working properly.

lovettchris commented 6 months ago

Ok I published new version, so this is fixed in 2.9.0.8

slundahl2 commented 6 months ago

Thanks, Chris. It no longer crashes. I am able to open the file. I don't have time today to work with it but as a developer, I'm curious what was making it crash.

On Thu, Mar 21, 2024 at 11:31 PM Chris Lovett @.***> wrote:

Ok I published new version, so this is fixed in 2.9.0.8

— Reply to this email directly, view it on GitHub https://github.com/microsoft/XmlNotepad/issues/371#issuecomment-2014283872, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABS5A7WCDIBD2MLNF7ICT4DYZOQXXAVCNFSM6AAAAABEEAL7MWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJUGI4DGOBXGI . You are receiving this because you authored the thread.Message ID: @.***>

lovettchris commented 6 months ago

Hi Steven, it was a bug, your schema set is very complex which turned out to be a great test, it exposed a bug in the schema handling, the actual fixes are in the SchemaCache.cs and Checker.cs in this commit. The proxy.cs changes moving to HttpClient also helps with loading of your schemas, the old WebRequest was timing out on some of them when I was testing it.

slundahl2 commented 6 months ago

Glad it helped improve the product and thanks so much for fixing it!

Some time ago I tried using a pricey XML tool (I don't remember which one now -- it was a few years ago) and pointing it to the XSL and that tool kind of freaked out so I've been hand-coding these XML documents (and despite only publishing only one journal a year I'm still years behind, but then, it is a volunteer thing). I started to write my own in .NET -- more of a templating engine for our specific purpose -- but didn't finish it.

We're going to be moving our journal to an open source online platform that will create the XML registrations and submit them to Crossref.org at the click of a button so I won't have to hand-code them anymore. The major publishers all have paid development teams to do this, of course but our music membership organization has two musicians who are also developers that are doing all the techie stuff (and it was only me for over 20 years) and we have our day gigs AND our night gigs and try to squeeze the volunteer techie stuff in between.

Looking forward to using this tool now that it appears to be happy!

Thanks again!

Steve Lundahl

On Fri, Mar 22, 2024 at 3:11 PM Chris Lovett @.***> wrote:

Hi Steven, it was a bug, your schema set is very complex which turned out to be a great test, it exposed a bug in the schema handling, the actual fixes are in the SchemaCache.cs and Checker.cs in this commit https://github.com/microsoft/XmlNotepad/pull/372/files#diff-aaa34ad048e64842b9bed86ac731cb0f088164135c536bbf6474c9bf78a29847. The proxy.cs changes moving to HttpClient also helps with loading of your schemas, the old WebRequest was timing out on some of them when I was testing it.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/XmlNotepad/issues/371#issuecomment-2015748138, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABS5A7UGT5VEOSW3G36C7EDYZR67LAVCNFSM6AAAAABEEAL7MWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJVG42DQMJTHA . You are receiving this because you authored the thread.Message ID: @.***>