我正在實現一個事件結構來將信息從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