は、通常、私は行くだろう:リフレクションによってBackgroundWorker RunWorkerCompletedイベントを追加する方法はありますか?
bgwExportGrid.RunWorkerCompleted += ReportManager.RunWorkerCompleted;
ReportManagerクラスは、私が使用するイベントハンドラを含む静的クラスです。
public static class ReportManager
{
public static void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
...
}
}
は今、私はBackgroundWorkerのを作成し、ReportManagerで定義されているようRunWorkerCompletedイベントを添付するています。ただし、ReportManagerを参照することはできません。そうしないと循環参照が発生するため、リフレクションが必要になります。
ご協力いただければ幸いです。
私は、次のを見てきましたが、非常に遠くもらっていない:
Assembly assem = Utils.GetAssembly("WinUI.Reporting.Common.dll");
Type reportManagerType = assem.GetModule("WinUI.Reporting.Common.dll").GetType("WinUI.Reporting.Common.ReportManager");
EventInfo evWorkerCompleted = reportManagerType.GetEvent("RunWorkerCompleted");
Type tDelegate = evWorkerCompleted.EventHandlerType;
あなたは本当にこのコーナーに自分自身を塗装するべきではありません...私はリフレクションを使用する必要がある理由である、全くReportManagerクラスを参照することができないとして、私は上記の操作を行うことができない一般的なアセンブリ –