Importing service agent into a service agent

Oct 18, 2012 at 8:27 AM
Edited Oct 24, 2012 at 10:27 AM

I'm trying to import a service agent as part of the ctor for another service agent.  Sample code... 

 

[ExportService(ServiceType.Runtime,typeof(ISampleServiceAgent))]
public class MySampleServiceAgent: ISampleServiceAgent
{
    public MySampleServiceAgent() {}
    ...methods...
}

...and...

[PartCreationPolicy(CreationPolicy.Shared)]
[ExportService(ServiceType.Runtime, typeof(IApplicationContext))]
public class DefaultApplicationContext: IApplicationContext
{
    private ISampleServiceAgent sampleServiceAgent;
    private DefaultApplicationContext() {}

    [ImportingConstructor]
    public DefaultApplicationContext(ISampleServiceAgent sampleServiceAgent)
    {
        this.sampleServiceAgent = sampleServiceAgent;
    }
    ...methods...
}

 

If I use the [ImportingConstructor] on the DefaultApplicationContext then MEF breaks and nothing gets bound in WPF.  Got no idea how I can debug this.  Obvious first question is... Am I doing something wrong?

Thanks, Darren

edit: fixed naming in sample code