I want to use Unity in my WPF application using VS2012, I defined unity container as follows:
IUnityContainer unityContainer = new UnityContainer();
unityContainer.RegisterType<IMainViewModel, MainViewModel>();
var window = unityContainer.Resolve<MainWindow>();
window.Show();
My window constructor looks as follows:
public MainWindow(IMainViewModel mainViewModel)
{
InitializeComponent();
this.DataContext = mainViewModel;
}
When I run the application I get the following error:
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'No matching constructor found on type 'WPFClient.MainWindow'. You can use the Arguments or FactoryMethod directives to construct this type.' Line number '3' and line position '9'.
What am I doing wrong?