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 at ICSharpCode.Decompiler.TypeSystem.TypeProvider.GetTypeFromReference #2241

Closed
manuc66 opened this issue Dec 9, 2020 · 2 comments
Labels

Comments

@manuc66
Copy link

manuc66 commented Dec 9, 2020

Steps to reproduce

  1. Open ILSpy
  2. Remove all assemblies
  3. Add a DLL
  4. Search for a method whose return code have a type that is "not found"
  5. Got to that method, decompiling is starting then an error popup is shown

Error message shown

image

---------------------------
Sorry, we crashed
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.

   at ICSharpCode.Decompiler.TypeSystem.TypeProvider.GetTypeFromReference(MetadataReader reader, TypeReferenceHandle handle, Byte rawTypeKind)

   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeTypeHandle(BlobReader& blobReader, Byte rawTypeKind, Boolean allowTypeSpecifications)

   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeType(BlobReader& blobReader, Boolean allowTypeSpecifications, Int32 typeCode)

   at System.Reflection.Metadata.Ecma335.SignatureDecoder`2.DecodeMethodSignature(BlobReader& blobReader)

   at System.Reflection.Metadata.MethodDefinition.DecodeSignature[TType,TGenericContext](ISignatureTypeProvider`2 provider, TGenericContext genericContext)

   at ICSharpCode.ILSpy.CSharpLanguage.GetEntityName(PEFile module, EntityHandle handle, Boolean fullName, Boolean omitGenerics)

   at ICSharpCode.ILSpy.Search.MemberSearchStrategy.Search(PEFile module, CancellationToken cancellationToken)

   at ICSharpCode.ILSpy.SearchPane.RunningSearch.<Run>b__9_0()

   at System.Threading.Tasks.Task.Execute()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at ICSharpCode.ILSpy.SearchPane.RunningSearch.<Run>d__9.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at ICSharpCode.ILSpy.SearchPane.<StartSearch>d__22.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
---------------------------
OK   
---------------------------

Details

  • Product in use: ILSpy
  • Version in use: version 6.2.1.6137
@manuc66 manuc66 added the Bug label Dec 9, 2020
@manuc66 manuc66 changed the title NullReferenceException - at ICSharpCode.Decompiler.TypeSystem.TypeProvider.GetTypeFromReference NullReferenceException at ICSharpCode.Decompiler.TypeSystem.TypeProvider.GetTypeFromReference Dec 9, 2020
@siegfriedpammer
Copy link
Member

siegfriedpammer commented Dec 9, 2020

I have added a possible fix for this. I am unable to reproduce the exception, so it would be nice, if you could test the latest nightly build (https://github.com/icsharpcode/ILSpy/actions/runs/410330156) as soon as it is done. Thanks!

@manuc66
Copy link
Author

manuc66 commented Dec 9, 2020

@siegfriedpammer it fixes the issue, thanks

matherm-aboehm referenced this issue in matherm-aboehm/ILSpy Mar 1, 2021
…Module reference.

Create a temporary MetadataModule with current ICompilation and MetadataReader objects, which can be used to resolve assembly references.
matherm-aboehm referenced this issue in matherm-aboehm/ILSpy Mar 8, 2021
…Module reference.

Create a temporary MetadataModule with current ICompilation and MetadataReader objects, which can be used to resolve assembly references.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2021
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