tags:

views:

241

answers:

2

What's the best way to detect whether an app is running in debug mode in Managed C++/C++/CLI?

+4  A: 

IsDebuggerPresent()?

Or if it's built with debug? For regular C++ it's easy (_DEBUG is defined), for managed I don't know.

Marcus Lindblom
+1  A: 
array<Object^>^ debuggableAttributes = Assembly::GetExecutingAssembly()->GetCustomAttributes(DebuggableAttribute::typeid, false);

Console::WriteLine(debuggableAttributes->Length > 0);

(The compiler adds a DebuggableAttribute to an assembly when compiled in debug mode)

Jim Arnold