をクラッシュオブジェクトダンパーを作るために私の試みです:リクエストにリフレクションを使用すると、ここでのw3wp.exeプロセス
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Inspector
{
public static class Inspector
{
public static string Inspect(this object o)
{
StringBuilder sb = new StringBuilder();
InspectObject(o, sb);
return sb.ToString();
}
private static void InspectObject(object o, StringBuilder sb)
{
Type objType = o.GetType();
if (objType == typeof(string))
sb.Append(o.ToString());
else
{
try
{
IList<PropertyInfo> props = new List<PropertyInfo>(objType.GetProperties());
foreach (PropertyInfo prop in props)
{
object propValue = null;
ParameterInfo[] ip = prop.GetIndexParameters();
if (ip.Length == 0)
{
propValue = prop.GetValue(o, null);
InspectObject(propValue, sb);
}
else
{
}
}
}
catch (Exception ex)
{
sb.Append(string.Format("Exception: {0}", ex.Message));
}
}
}
}
}
私はにHomeControllerのIndexメソッド、w3wp.exeのプロセスがクラッシュにRequest
(Request.Inspect()
)を点検するためにそれを使用していますtry-catchブロックはその仕事をしません。
実際には何が起こっていますか?マイクロソフトでは、処理されていない例外だけがw3wp.exeをクラッシュさせると言いますが、私はRequest.Inspect()
を親try-catchブロックにラップしています。
StackOverflow(再帰の一般的な結果です)はプロセスをkillして捕まえられないことに注意してください。 –