Brian
Brian

Reputation: 5956

Detect Debug Mode in Managed C++

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

Upvotes: 1

Views: 478

Answers (2)

Macke
Macke

Reputation: 25680

IsDebuggerPresent()?

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

Upvotes: 5

Jim Arnold
Jim Arnold

Reputation: 2268

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)

Upvotes: 1

Related Questions