C# MVVMLight+;MVVM对话框定位的部件';的清单定义与程序集引用不匹配
我的WPF项目中有MVVM Light和MvvmDialogs 如果我在ViewModelLocator的构造函数中有这一行C# MVVMLight+;MVVM对话框定位的部件';的清单定义与程序集引用不匹配,c#,wpf,mvvm,mvvm-light,C#,Wpf,Mvvm,Mvvm Light,我的WPF项目中有MVVM Light和MvvmDialogs 如果我在ViewModelLocator的构造函数中有这一行 SimpleIoc.Default.Register<IDialogService>(() => new DialogService(null, new DialogTypeLocator(), null)); SimpleIoc.Default.Reset(); SimpleIoc.Default.Register(()=>newdialogser
SimpleIoc.Default.Register<IDialogService>(() => new DialogService(null, new DialogTypeLocator(), null));
SimpleIoc.Default.Reset();
SimpleIoc.Default.Register(()=>newdialogservice(null,newdialogtypelocator(),null));
我在App.xaml的这一行中得到了这个警告。设计器没有绑定,但应用程序运行良好
<local:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
已为MvvmDialogs.IDialogService注册了一个工厂
如果在设计模式下禁用该行,则会出现此错误
定位的程序集清单定义与程序集引用不匹配
我做错了什么
编辑:这似乎是两个完全不同的问题。我删除了MvvmDialogs,但仍然有第二个错误
进一步调查后,在ViewModelLocator构造函数中使用ViewModelBase.IsInDesignModeStatic会引发第二个错误,在设计模式下注册DialogService会引发第一个错误——但是我需要ViewModelBase.IsInDesignModeStatic在设计模式下禁用它…我找到了这篇文章
我通过向注册DialogService解决了第一个问题
if (!SimpleIoc.Default.IsRegistered<IDialogService>())
SimpleIoc.Default.Register<IDialogService>(() => new DialogService(null, new DialogTypeLocator(), null));
问题#2的更好解决方案是使用它而不是ViewModelBase.IsIndesignatic
DesignerProperties.GetIsInDesignMode(new DependencyObject())