icsharpcode/ILSpy · error · ArgumentNullException
error
Error message
error
What it means
Thrown by CSharpDecompiler.GetErrorHeadline(DecompilerException error): error == null -> throw new ArgumentNullException(nameof(error)). The message is the parameter name 'error'. GetErrorHeadline formats a one-line description of a decompiler failure and requires a real exception.
Source
Thrown at ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs:327
/// <summary>
/// The headline a front end puts above the list of failures it recovered from. Shared so the
/// UI, the command line and any other consumer say the same thing and point at the same URL.
/// </summary>
public static IEnumerable<string> GetErrorSummaryLines(int errorCount)
{
yield return $"{errorCount} error(s) occurred; the affected code was replaced by the error text in the output.";
yield return $"Please report them at {DecompilationErrorReportUrl}:";
}
/// <summary>
/// The one-line description of a single failure, so the UI and the command line name it the
/// same way.
/// </summary>
public static string GetErrorHeadline(DecompilerException error)
{
if (error == null)
throw new ArgumentNullException(nameof(error));
return error.InnerException == null ? error.Message : $"{error.Message}: {error.InnerException.Message}";
}
/// <summary>
/// Renders <paramref name="error"/> as the lines of a comment block: an explanation, the
/// request to report it, and the full exception including its stack trace, which is what
/// makes such a report actionable.
/// </summary>
internal static IEnumerable<string> GetErrorCommentLines(Exception error)
{
yield return "ILSpy could not decompile this. Please report the exception below,";
yield return "along with the assembly it came from, at " + DecompilationErrorReportUrl;
foreach (string line in error.ToString().Split('\n'))
{
yield return line.TrimEnd('\r');
}
}
View on GitHub (pinned to 60c08fcb74)
Solutions
- Pass a non-null DecompilerException to GetErrorHeadline.
- Null-check the exception at the call site before formatting the headline.
Example fix
// before
var headline = CSharpDecompiler.GetErrorHeadline(maybeNullError);
// after
var headline = maybeNullError == null
? "Decompilation failed."
: CSharpDecompiler.GetErrorHeadline(maybeNullError); Defensive patterns
Strategy: validation
Validate before calling
if (error == null) throw new ArgumentNullException(nameof(error)); var headline = CSharpDecompiler.GetErrorHeadline(error);
Try / catch
var headline = error != null
? CSharpDecompiler.GetErrorHeadline(error)
: "Decompilation failed."; Prevention
- Coalesce null error objects before calling GetErrorHeadline.
When it happens
Trigger: Calling GetErrorHeadline(null) directly, or code that passed a null DecompilerException through to it.
Common situations: Internal/UI code path that obtained no exception object (e.g. a decompile list with a null entry) and forwarded it.
Related errors
- v
- typeSystem
- types
- Cannot use an uncached type system in the decompiler.
- Error decompiling module and assembly attributes of {module.
AI-assisted analysis of icsharpcode/ILSpy@60c08fcb74 (2026-08-13).
Data as JSON: /api/errors/c0c9d76b1ca0091a.
Report an issue: GitHub.