Click here to Skip to main content
Click here to Skip to main content

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

By , 1 Feb 2012
 
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)

About the Author

Huisheng Chen
Architect www.xnlab.com
Australia Australia
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralAh that could be a useful little function. Thanks for postin...memberSoftwareMonkeys2 Feb '12 - 19:30 
GeneralThis is the way to go - no guessing but asking the codes met...memberjohannesnestler1 Feb '12 - 4:28 
GeneralReason for my vote of 5 Yes, this is the way to go!memberjohannesnestler1 Feb '12 - 4:26 

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

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