C# Mvvm光信使奇怪的工作
我觉得这个问题有些奇怪。但例如,我有一些代码,比如C# Mvvm光信使奇怪的工作,c#,wpf,mvvm,mvvm-light,C#,Wpf,Mvvm,Mvvm Light,我觉得这个问题有些奇怪。但例如,我有一些代码,比如 Messenger.Default.Register<BinarySelectorCommunicator>(this, (emp) => { if (emp.Option == ((int)Games.HighLow).ToString()) { DB = null; DB = new HigLow(); DB.Boxes = new ObservableCol
Messenger.Default.Register<BinarySelectorCommunicator>(this, (emp) => {
if (emp.Option == ((int)Games.HighLow).ToString())
{
DB = null;
DB = new HigLow();
DB.Boxes = new ObservableCollection<BoxStruct>();
}
});
Messenger.Default.Register(此(emp)=>{
if(emp.Option==((int)Games.HighLow.ToString())
{
DB=null;
DB=新的HigLow();
DB.box=新的ObservableCollection();
}
});
它在调试模式下运行良好,编译器在每一行中输入。但是当我添加新函数时
Messenger.Default.Register<BinarySelectorCommunicator>(this, (emp) =>
{
if (emp.Option == ((int)Games.HighLow).ToString())
{
DB = null;
DB = new HigLow();
DB.Boxes = new ObservableCollection<BoxStruct>();
DB.inputAssets = new ObservableCollection<string>((from x in InputData select x.Id).Take(1));
}
});
Messenger.Default.Register(此(emp)=>
{
if(emp.Option==((int)Games.HighLow.ToString())
{
DB=null;
DB=新的HigLow();
DB.box=新的ObservableCollection();
DB.inputAssets=新的ObservableCollection((从InputData中的x选择x.Id)。取(1));
}
});
它不起作用。处于调试模式的编译器甚至不会进入messenger。我知道这个问题很奇怪。理论上为什么会发生这种情况?这是抛出异常?您能发布发送消息的代码吗?您是否可以确认,在测试时,您在if语句上放置了断点,而不是在if语句中?您需要重写您的问题。请注意,编译器不运行程序,它只检查语法。你的意思是对编译器说“我的程序”吗?所以它是在调试模式下运行的,您运行它的另一种模式是什么,它实际上是导致问题的。我们阅读这个问题时不清楚这种模式是什么。