icsharpcode/ILSpy · error · DecompilerException

Error decompiling module and assembly attributes of {module.

Error message

Error decompiling module and assembly attributes of {module.AssemblyName}

What it means

Thrown as a DecompilerException wrapping any non-cancellation, non-DecompilerException failure that occurs while decompiling the assembly's module-level and assembly-level attributes. The real cause is in InnerException; the message names the assembly. CSharpDecompiler deliberately catches broadly here so one bad attribute does not crash the whole decompilation silently.

Source

Thrown at ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs:921

			{
				foreach (var a in typeSystem.MainModule.GetAssemblyAttributes())
				{
					var astBuilder = CreateAstBuilder(decompileRun.Settings);
					var attrSection = new AttributeSection(astBuilder.ConvertAttribute(a));
					attrSection.AttributeTarget = "assembly";
					syntaxTree.Members.Add(attrSection);
				}
				foreach (var a in typeSystem.MainModule.GetModuleAttributes())
				{
					var astBuilder = CreateAstBuilder(decompileRun.Settings);
					var attrSection = new AttributeSection(astBuilder.ConvertAttribute(a));
					attrSection.AttributeTarget = "module";
					syntaxTree.Members.Add(attrSection);
				}
			}
			catch (Exception innerException) when (!(innerException is OperationCanceledException || innerException is DecompilerException))
			{
				throw new DecompilerException(module, null, innerException, "Error decompiling module and assembly attributes of " + module.AssemblyName);
			}
		}

		void DoDecompileTypes(IEnumerable<TypeDefinitionHandle> types, DecompileRun decompileRun, ITypeResolveContext decompilationContext, SyntaxTree syntaxTree)
		{
			string? currentNamespace = null;
			AstNode? groupNode = null;
			foreach (var typeDefHandle in types)
			{
				var typeDef = module.GetDefinition(typeDefHandle);
				if (typeDef.Name == "<Module>" && typeDef.Members.Count == 0)
					continue;
				if (MemberIsHidden(module.MetadataFile, typeDefHandle, settings))
					continue;
				if (string.IsNullOrEmpty(typeDef.Namespace))
				{
					groupNode = syntaxTree;
				}

View on GitHub (pinned to 60c08fcb74)

Solutions

  1. Inspect the InnerException (and its stack trace) for the actual cause.
  2. Resolve any missing assembly references the InnerException mentions and retry.
  3. If the attribute metadata is corrupt/obfuscated, report the assembly; the wrapper is doing its job by isolating the failure.

Example fix

// before
var tree = decompiler.DecompileWholeModuleAsSingleFile();

// after: surface the inner cause instead of just the wrapper
try {
    var tree = decompiler.DecompileWholeModuleAsSingleFile();
} catch (DecompilerException ex) {
    logger.Error(ex.InnerException ?? ex, "Attribute decompilation failed for {0}", ex.Message);
    throw;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    var tree = decompiler.DecompileWholeModuleAsSingleFile();
} catch (DecompilerException ex) when (ex.Message.Contains("module and assembly attributes")) {
    // real cause is ex.InnerException; check for missing references / corrupt metadata
    logger.Warning("Attribute decompile failed: {0}", ex.InnerException?.Message);
}

Prevention

When it happens

Trigger: An exception is raised inside DoDecompileModuleAttributes while iterating GetAssemblyAttributes()/GetModuleAttributes() or converting an attribute (e.g. unresolved attribute type, malformed custom-attribute blob, missing assembly reference).

Common situations: Obfuscated assemblies with malformed attribute metadata; custom attributes referencing types in assemblies the resolver cannot find; broken/security-decorated metadata.

Related errors


AI-assisted analysis of icsharpcode/ILSpy@60c08fcb74 (2026-08-13). Data as JSON: /api/errors/32d31a6adab3be34. Report an issue: GitHub.