This project has moved and is read-only. For the latest updates, please go here.

Assembly Caching Error

Mar 7, 2009 at 5:02 PM

I have been playing around with catalog caching based on an example from discussion:41362
With preview 4 the code example no longer works and I have created the following code....

var catalog = new AggregateCatalog();
AssemblyName _an = Assembly.GetExecutingAssembly().GetName();
String cacheCatalogPath = String.Format(@"{0}\MEFCache", Environment.CurrentDirectory);
String cacheCatalogFile = String.Format(@"{0}\{1}.dll", cacheCatalogPath, _an.Name);
if(File.Exists(cacheCatalogFile)) {
} else {
catalog.Catalogs.Add(new DirectoryCatalog(Environment.CurrentDirectory));
ComposablePartCatalogCachingServices.CacheCatalog(catalog, cacheCatalogFile);

however during the second run through I get the following error when trying to read from the cached dll

Invalid cache : type 'EntryPoint' is not found.

at System.ComponentModel.Composition.Caching.ComposablePartCatalogAssemblyCacheReader.GetCacheType(Assembly assembly, String name)
at System.ComponentModel.Composition.Caching.ComposablePartCatalogAssemblyCacheReader..ctor(Assembly cacheAssembly)
at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCachingServices.ReadCatalogFromCache(AssemblyName assemblyName)
at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCachingServices.ReadCatalogFromCache(String assemblyPath)
at MungleFish.Presenter.Player..ctor() in C:\Users\frazer\Documents\Backup\MEF_20090228.2\Presenter\MungleFish.Presenter.Player\Window1.xaml.cs:line 184

The dll appears to be been created correctly and the file path for the read is pointing to the dll.

Where am I going wrong?

Many Thanks

Mar 9, 2009 at 4:06 PM
Did you have an existing cache (dll file) created using the previous version of MEF?

One issue I ran into is that the cache files from prior versions of MEF are not compatible - so you have to make sure you delete any existing cache files and then recreate them using the new version.

No idea if this is what you're running into, but it's a thought.


Mar 9, 2009 at 9:43 PM
Hi Phil,

not so simple i'm affraid :-(

This was a clean build with no prior dll in existance.


Mar 9, 2009 at 10:01 PM
Hmm.  Have you taken a look at the created cache assembly with reflector?  Might be worth a look...

From what I can see of my cache assemblies, there is indeed a public static class named 'EntryPoint' in the assembly.

It might be worth checking to see if your cache assembly has this.  I would guess if that doesn't exist then it's *probably* some issue related to creation of the cache.  I know that's not very helpful, but it might help narrow it down a little.

Mar 9, 2009 at 10:14 PM
I assume there are some actual exports in the directory catalog?  Just wondering if it's doing something weird like not creating an entry point if it doesn't find any exports.


Mar 18, 2009 at 10:54 PM
Hi Phil,

sorry for the delay, the time vampires have been at me again ;-(

Reflector shows there is a class named EntryPoint.

What I have noticed is that none of the following classes are populated

I assume this is because I am using lazy loading i.e.

_container =

new CompositionContainer(catalog);


_logger = _container.GetExportedObjectOrDefault<


and the catalog never actually contains any interfaces.

I have got it to work using



new DirectoryCatalog(Environment.CurrentDirectory));

before I create the cache.

Is there any way to utilise both lazy loading and caching?

Many Thanks



Mar 18, 2009 at 11:28 PM
Hi guys

I wanted to give you an FYI (based on the fact that you are using our existing caching) that we are changing the caching story in our next drop. We've removed the caching APIs and are replacing them with a set of APIs that make it very easy to provide MEF information from a cache or otherwise that it can use to manufacture part definitions. Our next drop will be in a few weeks so you should be able to see it there.

Mar 21, 2009 at 11:56 PM
Hi Glenn,

Thanks for this.  I will eagerly await your next drop.

Keep up the good work