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

Export with Import

Sep 23, 2009 at 7:21 AM


Somehow I miss some point.

I try to do this:

A application (HOST) imports some Assemblies in a directory.
A Assemblies (Provider) needs some infos from the HOST.
So the HOST export the Interface ILastIndexValueEntries and the Provider imports it.


    class Host:ILastIndexValueEntries

        public Lazy<IProvider, IDictionary<string,object>>[] providers { get; private set; }

Assembly IProvider
    class DefaultProvider:IProvider
        private Lazy<ILastIndexValueEntries> dataSource { get; set; }

With the constelation above i didn't find a provider:

            //providers.Count() == 0

If i remove [Import(typeof(ILastIndexValueEntries))] in Assembly IProvider providers.Count()==1

What's wrong? Where is the bug?
Can someone help me?

Sep 23, 2009 at 8:34 AM

Found it...
I have to do this

var catalog = new AggregateCatalog(new ComposablePartCatalog[] {
                      new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()),
                      new DirectoryCatalog(providerpath) });

Thanks to me;-)