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

How to pass values to a constructor of a Part

Mar 31, 2011 at 2:22 AM


  I am new to MEF and I am wondering how i can pass specific values to a constructor of a class(that is exported) when it is beling instantiated. For eg: let's say i have a constructor as below

MyExportedType(MyType1 myt1, int i, MyType2 myt2)


and i want to pass specific values to these when MyExportedType is being created(initializing MyType1 and MyType2 in a certain way and then sending it to ctor ), the way i would do in code without MEF. Is that possible or would i be able to accomplish this only without MEF.

Thanks in advance

Apr 9, 2011 at 4:54 PM

MEF does not support passing specific values to a constructor during instantiation. In MEF the way to get parameters to objects is to Import them, and if you want specific parameters you would need to export those.