SelectConstructor problem! RRS feed

  • Question

  • Hi,

    I try to use custom constructor with SelectConstructor method in example bellow. But exception »No exports were found that match the constraint« is thrown at line container.GetExport<A>().

    Any idea what is wrong with sample code?



           class A


                 public A(string s)


                        Prop = s;


                 public string Prop { get; set; }


           class Class1


                 public object Test()


                        var rb = new RegistrationBuilder();

                        rb.ForType<A>().SelectConstructor(p=>new A("TestValue")).Export();

                        AssemblyCatalog catalog = new AssemblyCatalog(typeof(Class1).Assembly, rb);

                        CompositionContainer container = new CompositionContainer(catalog);

                        var export = container.GetExport<A>();

                        object value = export.Value;

                        return value;



    • Moved by Mike Feng Thursday, January 3, 2013 5:06 AM restructure .NET forums (From:Managed Extensibility Framework)
    Thursday, December 20, 2012 1:26 PM