Debugビルド判定(覚書) ― 2012年03月13日 22:52
//.Netアセンブリがデバッグビルドされているか否かの判定ロジック。
//ReflectionOnlyLoadFromを利用している為検査対象アセンブリのターゲットが
//実行プラットフォームと違っていても(x86、amd64関係なく)検証可能
Boolean result;
IList<CustomAttributeData> cadl;
try
{
result = false;
asm = Assembly.ReflectionOnlyLoadFrom(path);
cadl = CustomAttributeData.GetCustomAttributes(asm);
foreach (CustomAttributeData cad in cadl)
{
if (cad.Constructor.DeclaringType == typeof(DebuggableAttribute))
{
foreach (CustomAttributeTypedArgument ca in cad.ConstructorArguments)
{
if (ca.ArgumentType == typeof(DebuggableAttribute.DebuggingModes))
{
if (((DebuggableAttribute.DebuggingModes)ca.Value &
DebuggableAttribute.DebuggingModes.Default) ==
DebuggableAttribute.DebuggingModes.Default)
{
result = true;
}
}
}
}
}
return result;
}
catch (Exception ex)
{
throw ex;
}
最近のコメント