MEF Property Export with PartCreationPolicy
Posted
by Daniel Skinner
on Stack Overflow
See other posts from Stack Overflow
or by Daniel Skinner
Published on 2010-04-19T11:48:05Z
Indexed on
2010/04/19
11:53 UTC
Read the original article
Hit count: 823
MEF
|ioc-container
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.
© Stack Overflow or respective owner