我正在实现一个事件结构来将信息从View传递给Presenter。在视图中,单击一个按钮时,下面的代码被称为:调用委托时发生NotImplementedException
private void alterCmpd1()
{
EventHandler AlterEvent = AlterCompound1_Action;
if (AlterEvent != null) AlterEvent(this, EventArgs.Empty);
}
public event EventHandler AlterCompound1_Action;
出于某种原因,一个NotImplementedException总是出现在:
AlertEvent(this, EventArgs.Empty);
有人能帮助我弄清楚为什么?从发言类
代码:
public MainPresenter(IMainView view, IModel model)
{
this.view = view;
this.view.AlterCompound1_Action += new EventHandler(view_AlterCompound1);
this.model = model;
view.Show();
}
void view_AlterCompound1(object sender, EventArgs e)
{
// I commented out this code, on the off
// chance that it was affecting things. Still no luck.
}
不幸的是,没有。那会让我的生活更轻松。 – 2012-08-09 20:23:58
@QtotheC:我敢打赌,如果你删除了MainPresenter类,重新编译并运行异常会以任何方式发生。尝试一下。 – Will 2012-08-09 20:39:02
是的,你是对的。我认为它会抱怨在别的地方错过了一堂课。是什么造成的?这与我的代码文件在不同类中被拆分有什么关系?我在VS 2010工作,并告诉它重建解决方案。 – 2012-08-09 20:43:22