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

Crashes since 2.9.0.9 #386

Closed Pierre-de-la-Verre closed 5 months ago

Pierre-de-la-Verre commented 5 months ago

Since 2.9.0.9 it seems that "something makes problems". It takes longer to open a file, and sometimes it crashes.

Now I have the reproducible situation with two very small files:

I made a "repair installation" of XMLNotepad - no solution.

Files and my settings are attached.

`Informationen über das Aufrufen von JIT-Debuggen anstelle dieses Dialogfelds finden Sie am Ende dieser Meldung.


************** Ausnahmetext **************
System.Threading.ThreadStateException: Für den aktuellen Thread muss der STA-Modus (Single Thread Apartment) festgelegt werden, bevor OLE-Aufrufe ausgeführt werden können. Stellen Sie sicher, dass die Hauptfunktion mit STAThreadAttribute gekennzeichnet ist.
   bei System.Windows.Forms.WebBrowserBase.OnHandleCreated(EventArgs e)
   bei System.Windows.Forms.Control.WmCreate(Message& m)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.WebBrowserBase.WndProc(Message& m)
   bei System.Windows.Forms.WebBrowser.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Geladene Assemblys **************
mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9232.0 built by: NET481REL1LAST_C.
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll.
----------------------------------------
XmlNotepad
    Assembly-Version: 2.9.0.9.
    Win32-Version: 2.9.0.9.
    CodeBase: file:///C:/Program%20Files%20(x86)/LovettSoftware/XmlNotepad/XmlNotepad.exe.
----------------------------------------
XmlNotepad.Model
    Assembly-Version: 2.9.0.9.
    Win32-Version: 2.9.0.9.
    CodeBase: file:///C:/Program%20Files%20(x86)/LovettSoftware/XmlNotepad/XmlNotepad.Model.DLL.
----------------------------------------
netstandard
    Assembly-Version: 2.0.0.0.
    Win32-Version: 4.8.9037.0.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/netstandard/v4.0_2.0.0.0__cc7b13ffcd2ddd51/netstandard.dll.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9181.0 built by: NET481REL1LAST_C.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9236.0 built by: NET481REL1LAST_B.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9037.0 built by: NET481REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
Microsoft.XmlNotepad
    Assembly-Version: 2.9.0.9.
    Win32-Version: 2.9.0.9.
    CodeBase: file:///C:/Program%20Files%20(x86)/LovettSoftware/XmlNotepad/Microsoft.XmlNotepad.DLL.
----------------------------------------
System.Configuration
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9037.0 built by: NET481REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll.
----------------------------------------
System.Core
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9236.0 built by: NET481REL1LAST_B.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll.
----------------------------------------
System.Xml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9037.0 built by: NET481REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
Microsoft.Web.WebView2.WinForms
    Assembly-Version: 1.0.2151.40.
    Win32-Version: 1.0.2151.40.
    CodeBase: file:///C:/Program%20Files%20(x86)/LovettSoftware/XmlNotepad/Microsoft.Web.WebView2.WinForms.DLL.
----------------------------------------
Microsoft.Web.WebView2.Core
    Assembly-Version: 1.0.2151.40.
    Win32-Version: 1.0.2151.40.
    CodeBase: file:///C:/Program%20Files%20(x86)/LovettSoftware/XmlNotepad/Microsoft.Web.WebView2.Core.DLL.
----------------------------------------
mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------
Accessibility
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9037.0 built by: NET481REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll.
----------------------------------------
System.Net.Http
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9037.0 built by: NET481REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Net.Http/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.dll.
----------------------------------------
System.Data.SqlXml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.9037.0 built by: NET481REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Data.SqlXml/v4.0_4.0.0.0__b77a5c561934e089/System.Data.SqlXml.dll.
----------------------------------------
System.Xml.Xsl.CompiledQuery.1
    Assembly-Version: 0.0.0.0.
    Win32-Version: 4.8.9037.0 built by: NET481REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Data.SqlXml/v4.0_4.0.0.0__b77a5c561934e089/System.Data.SqlXml.dll.
----------------------------------------
System.xml.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Xml.resources.dll.
----------------------------------------

************** JIT-Debuggen **************
Um das JIT-Debuggen (Just-In-Time) zu aktivieren, muss in der
Konfigurationsdatei der Anwendung oder des Computers
(machine.config) der jitDebugging-Wert im Abschnitt system.windows.forms festgelegt werden.
Die Anwendung muss mit aktiviertem Debuggen kompiliert werden.

Zum Beispiel:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

Wenn das JIT-Debuggen aktiviert ist, werden alle nicht behandelten
Ausnahmen an den JIT-Debugger gesendet, der auf dem
Computer registriert ist, und nicht in diesem Dialogfeld behandelt.
`

```[problems.zip](https://github.com/microsoft/XmlNotepad/files/15127594/problems.zip)
lovettchris commented 5 months ago

Oh, looks like a serious bug, I'm on it right away. So far I am not able to reproduce this bug using the files you provided in problems.zip and the double click steps you provided. Both files open fine for me so I end up with 2 xml notepad windows. But I see a similar issue posted here: https://answers.microsoft.com/en-us/windows/forum/all/microsoft-net-framework-encounters-jit-debugging/4aeaf8bc-304b-4c89-a372-ad470ccdc72e So I'm investigating, your trace above mentions NET48REL1, so I'll look for that version.

lovettchris commented 5 months ago

I see here that .NET 4.81 is available in a windows update for Windows 11 21H2, Windows 10 21H2 (LTSC), and Windows 10 22H2 according to https://devblogs.microsoft.com/dotnet/upcoming-availability-of-net-framework-4-8-1-on-windows-update-and-catalog/

I happen to be on Windows 11 23H2. What version of windows are you using? When I load my XmlNotepad into the debugger it shows the same versions of .NET have been loaded no problem (specifically version v4.0_4.0.0.0__b77a5c561934e089)

XmlNotepad.exe' (CLR v4.0.30319: XmlNotepad.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Symbol loading disabled by Include/Exclude setting.

lovettchris commented 5 months ago

I see the stack trace involves the "System.Windows.Forms.WebBrowser" and I see you are using "BrowserVersion" = "WebView2". Could you try changing your settings to use "WinformsWebBrowser" just to see if that makes a difference? If so we might have a webview2 installation problem.

The error message about [Single Thread Apartment] is confusing because the app already does that for the main thread, but this is a native callback so I'm now sure where that is coming from.

Can you run these too commands from a "cmd" prompt window and send me the output?

reg query HKEY_CLASSES_ROOT\.xml /s
reg query HKEY_CLASSES_ROOT\xmlfile /s

You should see something like this:

(sr) C:\temp\XmlNotepad>reg query HKEY_CLASSES_ROOT\.xml /s

HKEY_CLASSES_ROOT\.xml
    (Default)    REG_SZ    xmlfile
    Content Type    REG_SZ    text/xml
    PerceivedType    REG_SZ    text

HKEY_CLASSES_ROOT\.xml\OpenWithProgids
    MSEdgeHTM    REG_SZ
    VisualStudio.xml.e814adae    REG_SZ
    VSCode.xml    REG_SZ
    XmlNotepad.xmlfile    REG_SZ

HKEY_CLASSES_ROOT\.xml\PersistentHandler
    (Default)    REG_SZ    {7E9D8D44-6926-426F-AA2B-217A819A5CCE}

(sr) C:\temp\XmlNotepad>reg query HKEY_CLASSES_ROOT\xmlfile /s

HKEY_CLASSES_ROOT\xmlfile
    (Default)    REG_SZ    XML Document
    EditFlags    REG_BINARY    00002000
    FriendlyTypeName    REG_EXPAND_SZ    @%SystemRoot%\System32\msxml3r.dll,-1

HKEY_CLASSES_ROOT\xmlfile\CLSID
    (Default)    REG_SZ    {48123BC4-99D9-11D1-A6B3-00C04FD91555}

HKEY_CLASSES_ROOT\xmlfile\DefaultIcon
    (Default)    REG_SZ    "%1"

HKEY_CLASSES_ROOT\xmlfile\shell
    (Default)    REG_SZ    open

HKEY_CLASSES_ROOT\xmlfile\shell\edit

HKEY_CLASSES_ROOT\xmlfile\shell\edit\command
    (Default)    REG_SZ    "C:\Program Files (x86)\Microsoft Office\Root\VFS\ProgramFilesCommonX86\Microsoft Shared\Office16\MSOXMLED.EXE" /verb edit "%1"

HKEY_CLASSES_ROOT\xmlfile\shell\open

HKEY_CLASSES_ROOT\xmlfile\shell\open\command
    (Default)    REG_SZ    "C:\Program Files (x86)\Microsoft Office\Root\VFS\ProgramFilesCommonX86\Microsoft Shared\Office16\MSOXMLED.EXE" /verb open "%1"

HKEY_CLASSES_ROOT\xmlfile\shell\open\ddeexec
    (Default)    REG_SZ

HKEY_CLASSES_ROOT\xmlfile\shell\open\ddeexec\topic
    (Default)    REG_SZ

HKEY_CLASSES_ROOT\xmlfile\ShellEx

HKEY_CLASSES_ROOT\xmlfile\ShellEx\IconHandler
    (Default)    REG_SZ    {AB968F1E-E20B-403A-9EB8-72EB0EB6797E}
lovettchris commented 5 months ago

Can you also try uninstall 2.9.0.9 and re-install 2.9.0.8 and tell me if this works?

lovettchris commented 5 months ago

I found and fixed some issues, please also try this new version: https://github.com/microsoft/XmlNotepad/releases/tag/2.9.0.10

Pierre-de-la-Verre commented 5 months ago

Hi Chris thanks for your dedicated support. I tried now:

a) current Version 0.9 with WebView2: I could open and close some files, but suddenly (maybe after closing my first "group of sessions) the problems began again

b) current version 0.9 with WinFormsBrowser: no problems.

c) new installation of version 0.8: no problems, neither with WebView2 nor with WinFormsBrowser

d) new installation of version 0.10: no problems, neither with WebView2 nor with WinFormsBrowser

c) new installation of version 0.9: see chapter a) above ..

It seems that you fixed the problem ;-))

lovettchris commented 5 months ago

Ok, phew! Glad it is fixed. Thanks for the thorough testing, and prompt reporting, you are really helping to increase the quality of XML Notepad :-)