判断程序集在debug模式下关闭程序
public static class Check
{
public static void checkAssembly()
{
Assembly[] aseeemblys = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in aseeemblys)
{
if (DebugHelper.DebugBuild(assembly))
{
Environment.Exit(-1);
}
}
}
}
public static class DebugHelper
{
public static bool DebugBuild(string path)
{
return DebugBuild(Assembly.LoadFile(Path.GetFullPath(path)));
}
public static bool DebugBuild(Assembly assembly)
{
foreach (object attribute in assembly.GetCustomAttributes(false))
{
if (attribute is DebuggableAttribute)
{
DebuggableAttribute _attribute = attribute as DebuggableAttribute;
return _attribute.IsJITTrackingEnabled;
}
}
return false;
}
}