Hello, newby MEF here: I have 2 interfaces to classlibraries I want to compose with my main application. What i am trying to achieve is a directory of .dlls that I can update/manage for the application as a whole.
[InheritedExport] public interface IObject1 { method1(); method2(); } [InheritedExport] public interface IObject2 { method3(); method4(); }
Now in the main application thread, I get an error duplicate 'Import' attributes. I want to use both objects in my main application, I just don't know how to import them properly.
#region Imports section [Import(typeof(Object1), AllowRecomposition = true)] [Import(typeof(Object2), AllowRecomposition = true)] private Object1 _obj1; private Object2 _obj2; #endregion private void Compose() { dirCatalog = new DirectoryCatalog(@"D:\Folder"); AssemblyCatalog assemblyCat = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()); AggregateCatalog catalog = new AggregateCatalog(assemblyCat, dirCatalog); CompositionContainer container = new CompositionContainer(catalog); container.ComposeParts(this); }