How can I know whether the app is running in development mode?  
Author Message
Jordi Serres





PostPosted: Visual C# General, How can I know whether the app is running in development mode? Top

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



Visual C#20  
 
 
boban.s





PostPosted: Visual C# General, How can I know whether the app is running in development mode? Top

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.

 
 
Andrej Tozon





PostPosted: Visual C# General, How can I know whether the app is running in development mode? Top

Hi,

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

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

Andrej



 
 
Jordi Serres





PostPosted: Visual C# General, How can I know whether the app is running in development mode? Top

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.


 
 
Jordi Serres





PostPosted: Visual C# General, How can I know whether the app is running in development mode? Top

That's it!.

A million thanks, Andrej!