イベント/デリゲートをいじっていますが、常に次のエラーが発生します:
型 'System.Reflection.TargetInvocationException' の未処理の例外が PresentationFramework.dll で発生しました
追加情報: 呼び出しのターゲットによって例外がスローされました。
私のコードは次のとおりです。
namespace Test
{
using System;
using System.Windows;
public partial class TestWindow : Window
{
public TestWindow()
{
this.InitializeComponent();
this.TestEvent(this, new EventArgs());
}
public delegate void TestDelegate(object sender, EventArgs e);
public event TestDelegate TestEvent;
}
}
明らかに、別の場所に TestWindow オブジェクトを開くためのコードがあります。
TestWindow testWindow = new TestWindow();
testWindow.TestEvent += this.TestMethod;
と:
private void TestMethod(object sender, EventArgs e)
{
}