Still Unable To Load Mef Component Dll
If you prefer an automated method, you can use the by Mads Kristensen.
If clearing the cache fails, the DLL itself might be restricted by Windows:
While rare, MEF can hang on a DLL that has malformed [Export] attributes, cyclical imports, or attempts to export a non-public type from a non-public class. This usually manifests as a ReflectionTypeLoadException .
Are you loading the same assembly via reflection elsewhere? Is the DLL also in the GAC or app’s probing path? still unable to load mef component dll
private readonly AggregateCatalog _catalog = new AggregateCatalog(); public SafeDirectoryCatalog(string path)
– Read the DLL into memory and load it manually, bypassing file locks:
– Solves zombie file locks from unmanaged processes. If you prefer an automated method, you can
You get BadImageFormatException in logs. The error mentions "attempt to load a program with an incorrect format."
// Recreate the container from scratch var catalog = new DirectoryCatalog(pluginPath); container = new CompositionContainer(catalog);
The error is rarely a bug in MEF itself. It is almost always a symptom of an environmental issue: a locked file, a missing dependency, a bitness mismatch, or a corrupted deployment. Are you loading the same assembly via reflection elsewhere
try
Below is a comprehensive guide to resolving this persistent issue. 1. Clear the Visual Studio Component Cache
The most effective fix for this error is clearing the ComponentModelCache , which stores metadata about installed extensions and components.