How can I know whether the app is running in development mode?

Some of the features included in the application I'm currently developing are supposed to be used in 'administrator' mode, but, in fact, the only administrator is the developer and it's likely that none of these will be used by final users.

Therefore, instead of defining a particular user to be the administrator, why not letting the application to know wheter it is running whithin the development environement or as a standalone, compiled application

I remember a property like this was exposed in VB6, and I assume it is also included in the .net environement, but after some time of messing with the object browser and the internet, I give up and ask for HELP!

Where can I find this property



Answer this question

How can I know whether the app is running in development mode?

  • zolivier

    Hi,

    you can inspect Debugger.IsAttached property., It will return a value of true, if the debugger is attached to the process, which is the case when running within the IDE:

    if (System.Diagnostics.Debugger.IsAttached)
    {
       
    MessageBox.Show("I'm probably running within the VS IDE"
    );
    }

    Andrej



  • EthanS

    That's it!.

    A million thanks, Andrej!


  • DmitryMS

    I'ts a good solution.

    Though what I had in mind is something that could also be used in the event that the need arises to promote the application to administrator mode.

    Thanks anyway, Boban.


  • Randal Greene

    When developing App, dev is most of the time in Debug mode of project, and when you ship the app you are building Release version. So you can use this to set some diferent behaviour for debug and release configuration. I use this my self to remove login form when working in debug mode. The sintax for this is:
    #if DEBUG
    .... code to be executed only in debug configuration
    #else
    .... code to be executed only in release configuration
    #endif

    You can use either DEBUG or RELEASE.

  • How can I know whether the app is running in development mode?