{"record":{"id":"84284ebd7499de40","repo":"lucasg/Dependencies","slug":"cecil-could-not-correctly-parse-0-s-which-can-h","errorCode":null,"errorMessage":"Cecil could not correctly parse {0:s}, which can happens on .NET Core executables. CLR imports will be not shown","messagePattern":"Cecil could not correctly parse (.+?), which can happens on \\.NET Core executables\\. CLR imports will be not shown","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"DependenciesGui/DependencyWindow.xaml.cs","lineNumber":790,"sourceCode":"            // only mscorre triggers clr parsing\n            string User32Filepath = Path.Combine(FindPe.GetSystemPath(this.Pe), \"mscoree.dll\");\n            if (ImportModule.PeFilePath != User32Filepath)\n            {\n                return;\n            }\n\n            var resolver = new DefaultAssemblyResolver();\n            resolver.AddSearchDirectory(RootFolder);\n\n            // Parse it via cecil\n            AssemblyDefinition PeAssembly = null;\n            try\n            {\n                PeAssembly = AssemblyDefinition.ReadAssembly(AnalyzedPe.Filepath);\n            }\n            catch (BadImageFormatException)\n            {\n                MessageBoxResult result = MessageBox.Show(\n                        String.Format(\"Cecil could not correctly parse {0:s}, which can happens on .NET Core executables. CLR imports will be not shown\", AnalyzedPe.Filepath),\n                        \"CLR parsing fail\"\n                ); \n\n                return;\n            }\n\n            foreach (var module in PeAssembly.Modules)\n            {\n                // Process CLR referenced assemblies\n                foreach (var assembly in module.AssemblyReferences)\n                {\n                    AssemblyDefinition definition;\n                    try\n                    {\n                        definition = resolver.Resolve(assembly);\n                    }\n                    catch (AssemblyResolutionException)","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/lucasg/Dependencies/blob/1997a40000b77bd3326cbc33672a7b9f78bb23f3/DependenciesGui/DependencyWindow.xaml.cs#L772-L808","documentation":"Shown by DependencyWindow.ProcessClrImports (DependenciesGui/DependencyWindow.xaml.cs:790) when AssemblyDefinition.ReadAssembly (Mono.Cecil) throws BadImageFormatException for the analysed PE. ProcessClrImports only runs when the module imports mscoree.dll (i.e. looks like a .NET assembly), so a BadImageFormatException here means Cecil could not read the CLR metadata; CLR/managed imports are therefore skipped. A modal 'CLR parsing fail' MessageBox is shown and the method returns.","triggerScenarios":"Analysing a .NET assembly whose metadata Cecil cannot parse - common with .NET Core / .NET 5+ single-file, ready-to-run, or mixed-mode images, or a .NET binary produced by a newer toolchain than the bundled Cecil supports.","commonSituations":"Modern .NET (Core/5/6/7/8) executables; apphost-hosted single-file bundles; mixed-mode C++/CLI images; obfuscated/encrypted assemblies.","solutions":["Update Mono.Cecil to a version that supports the target .NET format and rebuild Dependencies.","For single-file .NET apps, extract the bundled assembly first and analyse that instead of the host exe.","Accept that CLR imports will be incomplete for this binary and rely on the native import table only."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Mirror the existing guard when calling Cecil programmatically.\nAssemblyDefinition asm;\ntry { asm = AssemblyDefinition.ReadAssembly(filepath); }\ncatch (BadImageFormatException)\n{\n    // CLR metadata unreadable - skip CLR import enumeration.\n    return;\n}","preventionTips":["Keep Mono.Cecil updated to support current .NET target frameworks; older Cecil throws BadImageFormatException on newer formats.","For single-file .NET apps, extract the inner assembly before analysis rather than feeding the apphost host to Cecil."],"tags":["gui","clr","cecil","badimageformat","dotnet"],"backgroundTag":null,"analyzedSha":"1997a40000b77bd3326cbc33672a7b9f78bb23f3","analyzedAt":"2026-08-13T18:14:41.696Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}