web.config または global.asax ファイルを変更せずに未処理のエラーをキャプチャできるかどうかを知りたいです。
理想的には、WebActivator パッケージを使用して、次のようなものを用意します。
[assembly: WebActivator.PostApplicationStartMethod(typeof(MyProject.Initialize), "Start")]
namespace MyProject
{
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
internal static Initialize
{
public static void Start()
{
// this doesn't work
HttpContext.Current.ApplicationInstance.Error += ApplicationInstance_Error;
}
// this never fires
static void ApplicationInstance_Error(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}
質問 #1: web.config または global.asax ファイルを変更せずに未処理のエラーをキャプチャすることは可能ですか?
質問 2: どのように?
更新:以下に回答を投稿しました。これが最善の方法かどうかはわかりません。コメントをお待ちしております。