Importing from referenced assembly - MEF
- by cmaduro
I have the following simplified code:
namespace Silverbits.Applications
{
public partial class SilverbitsApplication : Application
{
[Import("MainPage")]
public UserControl MainPage
{
get { return RootVisual as UserControl; }
set { RootVisual = value; }
}
public SilverbitsApplication()
{
this.Startup += this.SilverbitsApplication_StartUp;
this.Exit += new EventHandler(SilverbitsApplication_Exit);
this.UnhandledException += this.SilverbitsApplication_UnhandledException;
InitializeComponent();
}
private void SilverbitsApplication_StartUp(object sender, StartupEventArgs e)
{
CompositionInitializer.SatisfyImports(this);
}
}
namespace Manpower4U
{
public class App : SilverbitsApplication
{
public App() : base()
{
}
}
}
namespace Manpower4U
{
[Export("MainPage")]
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
}
}
The idea is that I have a Silverbits Library which is a completely different solution. And I have Manpower4U silverlight application that references my Silverbits library.
I want to export MainPage from Manpower4U and set it to the RootVisual in my SilverbitsApplication class.
SilverbitsApplication class is basically App.xaml/App.cs from the silverlight application, only I put it in a class library and subclassed App.cs file in Manpower4U, which is now the entry point of Manpower4U.
MEF cannot resolve the import. How do I get this to work?