Search code examples
c#.net-4.5mef

How to add only executing assembly in CompositionContainer without add AssemblyCatalog


Good day.

I need to be added executing assembly in CompositionContainer (MEF) without add AssemblyCatalog. Since this assembly has 20 reference on other project.

At now, I'm use next solution:

AssemblyCatalog asCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
AggregateCatalog agCatalog = new AggregateCatalog();
agCatalog.Catalogs.Add(asCatalog);

Thanks for help.


Solution

  • After watching the source code MEF, the issue resolved itself. AssemblyCatalog imports only the specified assembly.

    http://mef.codeplex.com/SourceControl/latest#redist/src/ComponentModel/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs