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

NullReferenceException in MetadataExtensions.ToHexString #2090

Closed
dsimon-pxc opened this issue Aug 4, 2020 · 3 comments
Closed

NullReferenceException in MetadataExtensions.ToHexString #2090

dsimon-pxc opened this issue Aug 4, 2020 · 3 comments
Labels

Comments

@dsimon-pxc
Copy link

Steps to reproduce

  1. Assembly contains a reference to specific mscorlib version
  2. Referenced mscorlib is not available in same directory as the assembly, exception is raised
  3. If the mscorelib is copied into the directory of the assembly, the exception is not thrown

Seems, that the tool tries to process a referenced assembly, even if it is not available.

Error message shown

System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
   bei ICSharpCode.Decompiler.Metadata.MetadataExtensions.ToHexString(IEnumerable`1 bytes, Int32 estimatedLength)
   bei ICSharpCode.Decompiler.Metadata.UniversalAssemblyResolver.GetCorlib(IAssemblyReference reference)
   bei ICSharpCode.Decompiler.Metadata.UniversalAssemblyResolver.ResolveInternal(IAssemblyReference name)
   bei ICSharpCode.Decompiler.Metadata.UniversalAssemblyResolver.FindAssemblyFile(IAssemblyReference name)
   bei ICSharpCode.ILSpy.LoadedAssembly.LookupReferencedAssemblyInternal(IAssemblyReference fullName, Boolean isWinRT, String tfm)
   bei System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   bei ICSharpCode.ILSpy.LoadedAssembly.LookupReferencedAssembly(IAssemblyReference reference)
   bei ICSharpCode.ILSpy.LoadedAssembly.MyAssemblyResolver.Resolve(IAssemblyReference reference)
   bei ICSharpCode.Decompiler.TypeSystem.DecompilerTypeSystem..ctor(PEFile mainModule, IAssemblyResolver assemblyResolver, TypeSystemOptions typeSystemOptions)
   bei ICSharpCode.ILSpy.CSharpLanguage.DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
   bei ICSharpCode.ILSpy.TreeNodes.AssemblyTreeNode.Decompile(Language language, ITextOutput output, DecompilationOptions options)
   bei ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput)
   bei ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass48_0.<DecompileAsync>b__0()

Details

  • Product in use: e.g. ILSpy / ICSharpCode.Decompiler nuget package / VS extension
  • Version in use: e.g. 6.0.0 or a commit hash (use Help>About to see which ILSpy version you are using)
  • Any other relevant information to the issue, or your interest in contributing a fix.
@dsimon-pxc dsimon-pxc added the Bug label Aug 4, 2020
@siegfriedpammer
Copy link
Member

Thank you for reporting this. This one is strange. Would you be able to provide the assembly that produces this exception?

Thank you very much!

@siegfriedpammer
Copy link
Member

We could always fix this by allowing the public key token to be null and fall back to "b77a5c561934e089", but I am not sure, whether there are assemblies where this wouldn't introduce more subtle bugs.

@dsimon-pxc
Copy link
Author

dsimon-pxc commented Aug 7, 2020

The package contains the mscorlib version with underscore. Trying to open a class in PLCnextBase_1_3_0.dll results in the exception described above. No exception occurs after rename of __mscorlib.dll to mscorlib.dll.

bin.zip

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants