×
Namespaces

Variants
Actions

Detecting app release/debug configuration

From Nokia Developer Wiki
Jump to: navigation, search

This article explains how to detect the application's configuration at run time which can be either DEBUG or RELEASE.

WP Metro Icon Bug.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
SignpostIcon Code 52.png
Article Metadata
Tested with
Devices(s): Nokia Lumia 920
CompatibilityArticle
Created: pooja_1650 (26 Jul 2013)
Last edited: hamishwillee (20 Nov 2013)

Contents

Introduction

At times, it is required to know about the configuration at run time under which the app is running. Possible scenarios are: to set some settings when the app is running under DEBUG mode only or to maintain logs when the app is not running with RELEASE configuration. In all such scenarios, knowing the configuration at run time can be very handy.

Prerequisites

  • Windows Phone development environment

Creating UI

To showcase the usefulness of detecting app configuration we will simply create a pivot page having default pivot item release having some UI controls. When the app will run under DEBUG configuration, we will create and show a new pivot item debug.
App running in Release configuration App running in Debug configuration

Code Behind

Following code snippet is used to check app configuration.

public PivotPage()
{
InitializeComponent();
CheckConfiguration();
}
 
public void CheckConfiguration()
{
#if DEBUG
PivotItem debugPivotItem = new PivotItem();
debugPivotItem.Header = "debug";
// add PivotItem content
mainPivot.Items.Add(debugPivotItem);
#endif
}

Build and Run

Now you may build the app and try to run it under both configurations to see the effects.

Summary

This way we can detect the app's configuration at run time.

References

This page was last modified on 20 November 2013, at 03:54.
102 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×