lucasg/Dependencies · warning
Cecil could not correctly parse {0:s}, which can happens on
Error message
Cecil could not correctly parse {0:s}, which can happens on .NET Core executables. CLR imports will be not shown What it means
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.
Source
Thrown at DependenciesGui/DependencyWindow.xaml.cs:790
// only mscorre triggers clr parsing
string User32Filepath = Path.Combine(FindPe.GetSystemPath(this.Pe), "mscoree.dll");
if (ImportModule.PeFilePath != User32Filepath)
{
return;
}
var resolver = new DefaultAssemblyResolver();
resolver.AddSearchDirectory(RootFolder);
// Parse it via cecil
AssemblyDefinition PeAssembly = null;
try
{
PeAssembly = AssemblyDefinition.ReadAssembly(AnalyzedPe.Filepath);
}
catch (BadImageFormatException)
{
MessageBoxResult result = MessageBox.Show(
String.Format("Cecil could not correctly parse {0:s}, which can happens on .NET Core executables. CLR imports will be not shown", AnalyzedPe.Filepath),
"CLR parsing fail"
);
return;
}
foreach (var module in PeAssembly.Modules)
{
// Process CLR referenced assemblies
foreach (var assembly in module.AssemblyReferences)
{
AssemblyDefinition definition;
try
{
definition = resolver.Resolve(assembly);
}
catch (AssemblyResolutionException)View on GitHub (pinned to 1997a40000)
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.
Defensive patterns
Strategy: try-catch
Try / catch
// Mirror the existing guard when calling Cecil programmatically.
AssemblyDefinition asm;
try { asm = AssemblyDefinition.ReadAssembly(filepath); }
catch (BadImageFormatException)
{
// CLR metadata unreadable - skip CLR import enumeration.
return;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Modern .NET (Core/5/6/7/8) executables; apphost-hosted single-file bundles; mixed-mode C++/CLI images; obfuscated/encrypted assemblies.
Related errors
- Loading PE file "{0:s}" failed : file not present on disk.
- Loading module {0:s} failed.
- Can only convert to string.
- Can only convert an instance of enum.
- {0:s} file could not be found !
AI-assisted analysis of lucasg/Dependencies@1997a40000 (2026-08-13).
Data as JSON: /api/errors/84284ebd7499de40.
Report an issue: GitHub.