在Managed C ++ / C ++ / CLI中检测应用程序是否以调试模式运行的最佳方法是什么?
答案 0 :(得分:5)
或者它是否使用调试构建?对于常规C ++,它很容易(定义了_DEBUG),对于托管我不知道。
答案 1 :(得分:1)
array<Object^>^ debuggableAttributes = Assembly::GetExecutingAssembly()->GetCustomAttributes(DebuggableAttribute::typeid, false);
Console::WriteLine(debuggableAttributes->Length > 0);
(在调试模式下编译时,编译器将DebuggableAttribute添加到程序集中)