This project is read-only.

Extending AppBootstrapper

Oct 8, 2012 at 8:25 PM

I've integrated Okra into my app, and I must say it's making things much easier.  One question I have is... how do you import additional services into your appbootstrapper?

I have, for instance, a SettingsCharmService : ISettingsCharmSerivce.  I tagged the class with [Export][Shared] and tagged its constructor with [ImportingConstructor].

Then in my AppBootstrapper I have:

[Import

]
public ISettingsCharmService SettingsCharmService { get; set; }

... is there something else I need to do?  I thought it would just wire itself in and use the default constructor, but when I try to run I get a "CompositionFailedException" - Missing dependency 'SettingsCharmService' on 'AppBootstrapper'.

Thanks for the help!
-Andy

 

Oct 8, 2012 at 8:42 PM

I think the issue is your Export attribute. By default the Export and Import attributes will pick up the export type from the type that is attributed. In your case you are exporting SettingsCharmService (since this is the class the Export attribute is on), but importing ISettingsCharmService (the type of the property) [i.e. export the class name, but import the interface name].

The solution is to change the export to [Export(typeof(ISettingsCharmService))], specifying that it is the interface you wish to export.

Hope this works for you,

   Andy

Oct 8, 2012 at 8:47 PM

... yup.  Sometimes it's the small things you forget.

Thanks!