The type ComposablePartCatalog cannot be constructed. You must configure the container to supply this value.

Jun 13, 2011 at 9:37 AM

   Hi

when i Resolve the OPV_CommonDictCrudService class ,it throw the follwoing exception,please give me some help ,thank you .

              IUnityContainer container2;
             container2 = new UnityContainer();      
             return container2.Resolve<OPV_CommonDictCrudService>();

exception message:

"Resolution of the dependency failed, type = "CRR.Services.OPV_CommonDictCrudService", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type ComposablePartCatalog cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving CRR.Services.OPV_CommonDictCrudService,(none)
  Resolving parameter "container" of constructor CRR.Services.OPV_CommonDictCrudService(System.ComponentModel.Composition.Hosting.CompositionContainer container)
    Resolving System.ComponentModel.Composition.Hosting.CompositionContainer,(none)
    Resolving parameter "catalog" of constructor System.ComponentModel.Composition.Hosting.CompositionContainer(System.ComponentModel.Composition.Primitives.ComposablePartCatalog catalog, System.Boolean isThreadSafe, System.ComponentModel.Composition.Hosting.ExportProvider[] providers)
      Resolving System.ComponentModel.Composition.Primitives.ComposablePartCatalog,(none)"

 

the Resolved OPV_CommonDictCrudService class:

public partial class OPV_CommonDictCrudService : OPV_CommonDictCrudServiceBase
    {       
        #region Constructors

        public OPV_CommonDictCrudService()
            : base()
        {
        }

        public OPV_CommonDictCrudService(MefHosting::CompositionContainer container)
            : base(container)
        {
        }

        #endregion
    }
   
    public abstract partial class OPV_CommonDictCrudServiceBase :   System.MarshalByRefObject ,IOPV_CommonDictCrudService
    {
        #region Constructors

        public OPV_CommonDictCrudServiceBase()
            : this(ContainerProvider.Container)
        {
        }

        public OPV_CommonDictCrudServiceBase(MefHosting::CompositionContainer container)
        {
            this.Container = container;
        }

        #endregion
       
        #region Protected Properties
       
        protected MefHosting::CompositionContainer Container { get; private set; }
       
        #endregion

        #region Public Methods

        public virtual DataContracts::OPV_CommonDictCrudInfo GetAll()
        {
            using (Entities::IUnitOfWork unitOfWork = DataAccess::UnitOfWork.Start())
            {
                Entities::IOPV_CommonDictRepository oPV_CommonDictRepository = this.Container.GetExportedValue<Entities::IOPV_CommonDictRepository>();
                DataContracts::OPV_CommonDictCrudInfo oPV_CommonDictCrudInfo = new DataContracts::OPV_CommonDictCrudInfo();
           
                oPV_CommonDictCrudInfo.OPV_CommonDictList = new global::System.Collections.ObjectModel.ObservableCollection<DataContracts::OPV_CommonDictValueObject>(DataAccess::OPV_CommonDictCrudTranslator.ToValueObject(oPV_CommonDictRepository.GetAll().OfType<Entities::OPV_CommonDict>().ToList()));
           
                   return oPV_CommonDictCrudInfo;
            }
        }

 

}

Jun 13, 2011 at 10:27 AM

  another part of the OPV_CommonDictCrudService:


    public partial class OPV_CommonDictCrudService : OPV_CommonDictCrudServiceBase
    {       
        #region Constructors

        public OPV_CommonDictCrudService()
            : base()
        {
        }

        public OPV_CommonDictCrudService(MefHosting::CompositionContainer container)
            : base(container)
        {
        }

        #endregion
    }
   
    public abstract partial class OPV_CommonDictCrudServiceBase :   System.MarshalByRefObject ,IOPV_CommonDictCrudService
    {
        #region Constructors

        public OPV_CommonDictCrudServiceBase()
            : this(ContainerProvider.Container)
        {
        }

        public OPV_CommonDictCrudServiceBase(MefHosting::CompositionContainer container)
        {
            this.Container = container;
        }

        #endregion

 

}

Jun 13, 2011 at 1:01 PM

Hi hackace,

Could you give us more background on what are you trying to achieve in your scenario. Unfortunately we can't able to easily reproduce your problem due to some other references you're using in your project (i.e. MefHosting). If you can simplify the classes you've provided then that'll be much better :o)

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com