Skip to content

Exception when assembly doesn't contain TargetFrameworkId data #2275

Closed
@jaredpar

Description

Steps to reproduce

Created a C# file called example.cs with the following content:

interface I1 { }

Then run the following command:

> dotnet exe "C:\Program Files\dotnet\sdk\5.0.101\Roslyn\bincore\csc.dll" example.cs /t:library /noconfig

Error message shown

Open the resulting example.dll file in ILSpy and you will get the following error message:

System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
   at System.String.Substring(Int32 startIndex, Int32 length)
   at ICSharpCode.Decompiler.Metadata.DotNetCorePathFinderExtensions.DetectTargetFrameworkId(PEReader assembly, String assemblyPath)
   at ICSharpCode.ILSpy.LoadedAssembly.<GetTargetFrameworkIdAsync>d__6.MoveNext()

Details

  • Product in use:ILSpy 6.2.1.6137

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions