Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICSharpCode.AvalonEdit.Highlighting.HighlightingDefinitionInvalidException: Error delay-loading highlighting definition #3301

Open
greenozon opened this issue Oct 8, 2024 · 8 comments
Labels

Comments

@greenozon
Copy link

Steps to reproduce

  1. drag-n-drop assemlby to the ILSpy
  2. error printed on the right hand panel

Error message shown

ICSharpCode.AvalonEdit.Highlighting.HighlightingDefinitionInvalidException: Error delay-loading highlighting definition
 ---> ICSharpCode.AvalonEdit.Highlighting.HighlightingDefinitionInvalidException: Root element is missing.
 ---> System.Xml.XmlException: Root element is missing.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlReader.MoveToContent()
   at ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.LoadXshd(XmlReader reader, Boolean skipValidation)
   --- End of inner exception stack trace ---
   at ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.LoadXshd(XmlReader reader, Boolean skipValidation)
   at ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.LoadXshd(XmlReader reader)
   at ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(XmlReader reader, IHighlightingDefinitionReferenceResolver resolver)
   at ICSharpCode.ILSpy.TextView.ExtensionMethods.<>c__DisplayClass0_0.<RegisterHighlighting>b__0()
   at ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.DelayLoadedHighlightingDefinition.GetDefinition()
   --- End of inner exception stack trace ---
   at ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.DelayLoadedHighlightingDefinition.GetDefinition()
   at ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.DelayLoadedHighlightingDefinition.GetNamedColor(String name)
   at ICSharpCode.ILSpy.CSharpHighlightingTokenWriter..ctor(TokenWriter decoratedWriter, ISmartTextOutput textOutput, ILocatable locatable)
   at ICSharpCode.ILSpy.CSharpLanguage.WriteCode(ITextOutput output, DecompilerSettings settings, SyntaxTree syntaxTree, IDecompilerTypeSystem typeSystem)
   at ICSharpCode.ILSpy.CSharpLanguage.DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
   at ICSharpCode.ILSpy.TreeNodes.AssemblyTreeNode.Decompile(Language language, ITextOutput output, DecompilationOptions options)
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput)
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass54_0.<DecompileAsync>b__0()

Details

  • ILSpy version 9.0.0.7812-preview2+c6e37529771dc55d29d26c8a9026bbf0f911ff03
    .NET version 8.0.8+08338fcaa5c9b9a8190abb99222fed12aaba956c

0Harmony.zip

@greenozon greenozon added the Bug label Oct 8, 2024
@greenozon
Copy link
Author

saved a vid
drag-dropped an assembly from here:
"c:\Program Files (x86)\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.identity.ui\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Identity.UI.dll"

vid-.2024-10-08.23-15-44-421.mp4

@siegfriedpammer
Copy link
Member

I downloaded the ILSpy debug build artifact from here https://github.com/icsharpcode/ILSpy/actions/runs/11204975456 (which is version 9.0.0.7812-preview2+c6e37529771dc55d29d26c8a9026bbf0f911ff03) and tried to load the 0Harmony.dll, but could not reproduce the error. Looking at the exception stacktrace to me it looks like the XSHD files embedded in ILSpy.dll are somehow broken on your machine.

I get the following hash:

PS ILSpy 9.0.0.7812-preview2 (Debug)\ILSpy_binaries> Get-FileHash -Algorithm SHA256 -Path ILSpy.dll
SHA256 A09C51D2992C48A29CD2B8AEED226DCEBB845EE0E0D17C4027320958B3125F1F ILSpy 9.0.0.7812-preview2 (Debug)\ILSpy_binaries\ILSpy.dll

Can you check on your machine? Thanks!

@greenozon
Copy link
Author

yeah, the SHA256 is equal to yours...
I'm not able to reproduce the issue today, sorry
I"ll try to gather pre-condiitinos and then get back
freel free to close this ticket in week-two if I did not find the repro

@greenozon
Copy link
Author

I reproduced the issue, but... it behaves randomly, not in 100% cases...
it appearsly more if the dll being drag-n-dropped is the 1st one in the tree
it almost does not appear if I drop it to non-empty tree

@greenozon
Copy link
Author

OK, the issue got reproduced, I've ran dnSpy and tried to debug ILSpy
here is the weird exception, @siegfriedpammer do you have some clues why it is so crazy?

image

image

is it possible to deduce what is going on from above cases?

@greenozon
Copy link
Author

why is lazyLoadingFunction == null?

image

might it be the reason for never ending exception I"m hitting on any click in right tree menu?

@greenozon
Copy link
Author

There is a single location in the ILSpy code that sets this field, but I never hit this breakpoint:

image

@siegfriedpammer
Copy link
Member

image

It is called from https://github.com/icsharpcode/ILSpy/blob/master/ILSpy/TextView/DecompilerTextView.cs#L99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants