Click here to Skip to main content
12,451,662 members (63,746 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

7.4K views
1 bookmarked
Posted

(C#) Determining whether the current build mode is Debug or Release

, 1 Feb 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Have a look this one, I just wrote: Accurate way to tell if an assembly is compiled in debug or release mode in c#[^] public static bool IsInDebugMode(string FileName) { var assembly = System.Reflection.Assembly.LoadFile(FileName); var attributes =...
Have a look this one, I just wrote: Accurate way to tell if an assembly is compiled in debug or release mode in c#[^]


public static bool IsInDebugMode(string FileName)
{
    var assembly = System.Reflection.Assembly.LoadFile(FileName);
    var attributes = assembly.GetCustomAttributes(typeof(System.Diagnostics.DebuggableAttribute), false);
    if (attributes.Length > 0)
    {
        var debuggable = attributes[0] as System.Diagnostics.DebuggableAttribute;
        if (debuggable != null)
            return (debuggable.DebuggingFlags & System.Diagnostics.DebuggableAttribute.DebuggingModes.Default) == System.Diagnostics.DebuggableAttribute.DebuggingModes.Default;
        else
            return false;
    }
    else
        return false;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Huisheng Chen
Product Manager www.xnlab.com
Australia Australia
I was born in the south of China, started to write GWBASIC code since 1993 when I was 13 years old, with professional .net(c#) and vb, founder of www.xnlab.com

Now I am living in Sydney, Australia.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralAh that could be a useful little function. Thanks for postin... Pin
SoftwareMonkeys2-Feb-12 19:30
memberSoftwareMonkeys2-Feb-12 19:30 
GeneralThis is the way to go - no guessing but asking the codes met... Pin
johannesnestler1-Feb-12 4:28
memberjohannesnestler1-Feb-12 4:28 
GeneralReason for my vote of 5 Yes, this is the way to go! Pin
johannesnestler1-Feb-12 4:26
memberjohannesnestler1-Feb-12 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 1 Feb 2012
Article Copyright 2012 by Huisheng Chen
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid