{"record":{"id":"32d31a6adab3be34","repo":"icsharpcode/ILSpy","slug":"error-decompiling-module-and-assembly-attributes-o","errorCode":null,"errorMessage":"Error decompiling module and assembly attributes of {module.AssemblyName}","messagePattern":"Error decompiling module and assembly attributes of (.+?)","errorType":"exception","errorClass":"DecompilerException","httpStatus":null,"severity":"error","filePath":"ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs","lineNumber":921,"sourceCode":"\t\t\t{\r\n\t\t\t\tforeach (var a in typeSystem.MainModule.GetAssemblyAttributes())\r\n\t\t\t\t{\r\n\t\t\t\t\tvar astBuilder = CreateAstBuilder(decompileRun.Settings);\r\n\t\t\t\t\tvar attrSection = new AttributeSection(astBuilder.ConvertAttribute(a));\r\n\t\t\t\t\tattrSection.AttributeTarget = \"assembly\";\r\n\t\t\t\t\tsyntaxTree.Members.Add(attrSection);\r\n\t\t\t\t}\r\n\t\t\t\tforeach (var a in typeSystem.MainModule.GetModuleAttributes())\r\n\t\t\t\t{\r\n\t\t\t\t\tvar astBuilder = CreateAstBuilder(decompileRun.Settings);\r\n\t\t\t\t\tvar attrSection = new AttributeSection(astBuilder.ConvertAttribute(a));\r\n\t\t\t\t\tattrSection.AttributeTarget = \"module\";\r\n\t\t\t\t\tsyntaxTree.Members.Add(attrSection);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tcatch (Exception innerException) when (!(innerException is OperationCanceledException || innerException is DecompilerException))\r\n\t\t\t{\r\n\t\t\t\tthrow new DecompilerException(module, null, innerException, \"Error decompiling module and assembly attributes of \" + module.AssemblyName);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvoid DoDecompileTypes(IEnumerable<TypeDefinitionHandle> types, DecompileRun decompileRun, ITypeResolveContext decompilationContext, SyntaxTree syntaxTree)\r\n\t\t{\r\n\t\t\tstring? currentNamespace = null;\r\n\t\t\tAstNode? groupNode = null;\r\n\t\t\tforeach (var typeDefHandle in types)\r\n\t\t\t{\r\n\t\t\t\tvar typeDef = module.GetDefinition(typeDefHandle);\r\n\t\t\t\tif (typeDef.Name == \"<Module>\" && typeDef.Members.Count == 0)\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\tif (MemberIsHidden(module.MetadataFile, typeDefHandle, settings))\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\tif (string.IsNullOrEmpty(typeDef.Namespace))\r\n\t\t\t\t{\r\n\t\t\t\t\tgroupNode = syntaxTree;\r\n\t\t\t\t}\r","sourceCodeStart":903,"sourceCodeEnd":939,"githubUrl":"https://github.com/icsharpcode/ILSpy/blob/60c08fcb74fcc183130f73c861ed35cf944d0bf1/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs#L903-L939","documentation":"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.","triggerScenarios":"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).","commonSituations":"Obfuscated assemblies with malformed attribute metadata; custom attributes referencing types in assemblies the resolver cannot find; broken/security-decorated metadata.","solutions":["Inspect the InnerException (and its stack trace) for the actual cause.","Resolve any missing assembly references the InnerException mentions and retry.","If the attribute metadata is corrupt/obfuscated, report the assembly; the wrapper is doing its job by isolating the failure."],"exampleFix":"// before\nvar tree = decompiler.DecompileWholeModuleAsSingleFile();\n\n// after: surface the inner cause instead of just the wrapper\ntry {\n    var tree = decompiler.DecompileWholeModuleAsSingleFile();\n} catch (DecompilerException ex) {\n    logger.Error(ex.InnerException ?? ex, \"Attribute decompilation failed for {0}\", ex.Message);\n    throw;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    var tree = decompiler.DecompileWholeModuleAsSingleFile();\n} catch (DecompilerException ex) when (ex.Message.Contains(\"module and assembly attributes\")) {\n    // real cause is ex.InnerException; check for missing references / corrupt metadata\n    logger.Warning(\"Attribute decompile failed: {0}\", ex.InnerException?.Message);\n}","preventionTips":["Always unwrap DecompilerException.InnerException for the actionable cause.","Ensure the assembly resolver can reach every assembly referenced by attributes."],"tags":["decompiler","csharp","attributes","assembly-resolution"],"backgroundTag":null,"analyzedSha":"60c08fcb74fcc183130f73c861ed35cf944d0bf1","analyzedAt":"2026-08-13T11:34:51.223Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}