Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

Go to top

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

, 1 Feb 2012
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
Technical Lead 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.
Follow on   Twitter   LinkedIn

Comments and Discussions

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

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web03 | 2.8.140926.1 | Last Updated 1 Feb 2012
Article Copyright 2012 by Huisheng Chen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid