If you're happy to assume that a program being executed from VS is being run in debug mode, you could always use the
#if DEBUG
macro. You can either use it in the code direct, such as:
public void MyFunction()
{
#if DEBUG
#endif
}
Or if you'd like your code to have access to this in several areas, consider making a static variable:
public static class Debugging
{
#if DEBUG
public static readonly bool IsActive = true;
#else
public static readonly bool IsActive = false;
#endif
}
But if you're wanting to also catch it if someone runs it in release mode as well, then you'd probably need to do a process look-up. I think it's
vshost.exe
or something that is attached to the process?