commandlineparser / commandlineparser/commandline

TypeLoadException on generating help text

Open
#779 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.8k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

Hi there,

a customer of ours gets this stack trace when our application is starting, and we are not able to determine whats going on. I traced it back in the source code to the first reflection call to getting a license attribute out of the executing assembly, but since our application is crashing immediately with no output I have to rely on whats event viewer has. And event viewer unfortunately does not tell me which type could not be loaded and why. Any ideas might be helpful:
```Application: App.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeLoadException
at System.ModuleHandle.ResolveType(System.Reflection.RuntimeModule, Int32, IntPtr*, Int32, IntPtr*, Int32, System.Runtime.CompilerServices.ObjectHandleOnStack)
at System.ModuleHandle.ResolveTypeHandleInternal(System.Reflection.RuntimeModule, Int32, System.RuntimeTypeHandle[], System.RuntimeTypeHandle[])
at System.Reflection.RuntimeModule.ResolveType(Int32, System.Type[], System.Type[])
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(System.Reflection.CustomAttributeRecord, System.Reflection.MetadataImport, System.Reflection.Assembly ByRef, System.Reflection.RuntimeModule, System.Reflection.MetadataToken, System.RuntimeType, Boolean, System.Object[], System.Collections.IList, System.RuntimeType ByRef, System.IRuntimeMethodInfo ByRef, Boolean ByRef, Boolean ByRef)
at System.Reflection.CustomAttribute.GetCustomAttributes(System.Reflection.RuntimeModule, Int32, Int32, System.RuntimeType, Boolean, System.Collections.IList, Boolean)
at System.Reflection.CustomAttribute.GetCustomAttributes(System.Reflection.RuntimeAssembly, System.RuntimeType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(System.Type, Boolean)
at System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, Boolean)
at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Reflection.Assembly)
at CommandLine.Infrastructure.ReflectionHelper.GetAttribute[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]()
at CommandLine.Text.HelpText.AutoBuild[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](CommandLine.ParserResult`1, System.Func`2, System.Func`2, Boolean, Int32)
at CommandLine.Text.HelpText.AutoBuild[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](CommandLine.ParserResult`1, Int32)
at CommandLine.Parser+<>c__DisplayClass17_0`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].b__1(System.Collections.Generic.IEnumerable`1, System.IO.TextWriter)
at CSharpx.MaybeExtensions.Do[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](CSharpx.Maybe`1>, System.Action`2)
at CommandLine.Parser+<>c__DisplayClass17_0`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].b__0(System.Collections.Generic.IEnumerable`1)
at CommandLine.ParserResultExtensions.WithNotParsed[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](CommandLine.ParserResult`1, System.Action`1>)
at CommandLine.Parser.DisplayHelp[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](CommandLine.ParserResult`1, System.IO.TextWriter, Int32)
at CommandLine.Parser.MakeParserResult[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](CommandLine.ParserResult`1, CommandLine.ParserSettings)
at CommandLine.Parser.ParseArguments[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1)
at App.Program.Main(System.String[])```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at CommandLine.Infrastructure.ReflectionHelper.GetAttribute and follow the call path through CommandLine.Text.HelpText.AutoBuild and Parser.DisplayHelp, using the stack trace as the entry point. Reproduce the startup failure if possible and identify which type or assembly attribute cannot be loaded and why; a useful outcome would be a confirmed cause and a narrowly defined fix or diagnostic improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.