How do I setup mef with a class library?
===

I've recently started using MEF in my application, and have had no issues using it or testing classes that it acts upon inside of my main application; however, I'm just now starting to create a licensing library for my application, have run into some issues, since I'm unsure of how to set it up.

In my licensing library, I've got LicenseManager, LicenseValidator, and LicenseSigner classes:

<!-- language: lang-cs -->

    public class LicenseManager
    {
        [Import]
        private ILicenseValidator _validator;
    
        [Import]
        private ILicenseSigner _signer;
    
        public LicenseManager()
        {
            var container = new CompsitionContainer();
            container.ComposeParts();
        }
    }
    
    [Export(typeof(ILicenseSigner))]
    public class LicenseSigner : ILicenseSigner
    {
        ...
    }
    
    [Export(typeof(ILicenseValidator))]
    public class LicenseValidator : ILicenseValidator
    {
        ...
    }

I get an error along the lines of:

    No exports were found that match the constraint:
        ContractName    LicenseManager.ILicenseSigner
        RequiredTypeIdentity    LicenseManager.ILicenseSigner

Which I assume is due to the fact that I'm instantiating LicenseManager before the constructor for LicenseManager can create the container; however, I'm not entirely sure how to solve the problem, since LicenseManager is intended as the only entry point into the class library. I could possibly create some sort of factory to initialize the container and return a LicenseManager instance, but that would result in a less nice library API.

I'm sort of new to the whole MEF thing.  Is there something I could be doing better?  Is there a way for me to take care of all the MEF loading in my main application?  Any solution is better than the lack of one that I have now.