我想在使用VS2012的
WPF应用程序中使用Unity,我将Unity容器定义如下:
IUnityContainer unityContainer = new UnityContainer(); unityContainer.RegisterType<IMainviewmodel,Mainviewmodel>(); var window = unityContainer.Resolve<MainWindow>(); window.Show();
我的窗口构造函数如下所示:
public MainWindow(IMainviewmodel mainviewmodel) { InitializeComponent(); this.DataContext = mainviewmodel; }
当我运行该应用程序时,我收到以下错误:
An unhandled exception of type
‘System.Windows.Markup.XamlParseException’ occurred in
PresentationFramework.dllAdditional 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’.
我究竟做错了什么?