This project has moved. For the latest updates, please go here.

MEF Container Initialization

Mar 19, 2013 at 11:39 PM
I have a problem initializing MEF. I built an application that uses MEF and it seems to work fine on a WIndows 8 and Windows 7 SP1 machines. However, when I run the application on a third machine (windows 7 SP1) I get a ImportCardinalityMismatchException during the container.Compose method. I don't know why the application runs fine on two machines and on another it does not. Any suggestions? Here is my initialization:
        private void ComposeMef()
            var catalog = new AggregateCatalog(
                    new DirectoryCatalog("."),
                    new AssemblyCatalog(Assembly.GetExecutingAssembly()));

            var batch = new CompositionBatch();

            _container = new CompositionContainer(catalog);
Mar 20, 2013 at 12:08 AM
I figured it out. The third machine was missing an updated library (.dll) that had the export