Please enable Javascript for better experience...
Check if solution is in Debug/Release mode
By Rahul Kumar Jha | Jul 25, 2014 | In Articles | Update: Sep 16, 2014 | Total Views [ 8793 ]
Taged In
(1 Like)
Rate

In this article I will show how to check whether application/ solution is in debug mode or in release mode.

Introduction

Everytime we deploy application code on live/production environment, we want to change certain settings like database connection, email settings etc. Production settings are always different then what we use at development/local environment. For this we use application configuration setting. We keep separating settings for debug and release mode in web.config file where generally we have separate files for both. We can add our custom mode also but that we can discuss later. This was about how we can change settings through web.config file. Now suppose in code behind we are writing two set of code and we want that on run time application should find whether it is in debug mode or release mode and should execute the code set accordingly. We can do this very easily. Let's see how we can check this.

Code

To identify whether application is in debug/release mode, we can use pre-defined system variable DEBUG or RELEASE. We can simply put a check and can execute respected code. One thing I want to add here is that if application is in debug mode then deug part in condition will be active and else part will be gray and vice versa. This is very quick way to check that in current configuration setting which part of code will execute.

#if DEBUG

            Console.Write("This part will execute when application configuration is set to debug mode.");
#else
            Console.Write("This part will execute when application configuration is set to release mode.");
#endif

See this was so simple to use. So use it and enjoy. You can set your code accordingly. I will come back with another such tips

Share this

About the Author

Rahul Kumar Jha
Rahul Kumar Jha
Founder, Developer dotnet-concept.com

Public profile: user/profile/99900001


Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, ANGULAR, ANGULAR JS, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
 
 
 
 
 
Sponsors