MEF Property Export with PartCreationPolicy
- by Daniel Skinner
When I try to do this:
[Export(typeof(IMyService))]
[PartCreationPolicy(CreationPolicy.Shared)]
private MyService Service
{
get
{
var service = new MyService();
service.Configure();
return service;
}
}
I get a compile error: Attribute 'PartCreationPolicy' is not valid on this declaration type. It is only valid on 'class' declarations.
Is this a bug? I don't see why MEF would allow property exports but not allow one to specify the part lifetime.
Using VS2010 RC.