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

Tagged as

Go to top

Preventing stubbed methods from being released

, 15 Oct 2011
Rate this:
Please Sign up or sign in to vote.
Very nice tips indeed!A somewhat different approach to this might be to use the Debugger.IsAttached[^] static property.Though this works somewhat different.if (System.Diagnostics.Debugger.IsAttached){ // This code executes when starting from VS either in release or debug...
Very nice tips indeed!
A somewhat different approach to this might be to use the Debugger.IsAttached[^] static property.
Though this works somewhat different.
if (System.Diagnostics.Debugger.IsAttached)
{
   // This code executes when starting from VS either in release or debug mode.
}
else
{
   // This code executes when starting from outside VS either in release or debug mode.
}
This looks more .NETish, but also performs differently as you can see.
I have used it many times for debugging purposes (for example, giving a value to a variable only for debugging).
Though not really a substitute for the above tips, I thought I should include this for completeness. Smile | :)

License

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

Share

About the Author

Sander Rossel
Software Developer
Netherlands Netherlands
Started programming in 2010 after completing a Bachelor Common Art and Cultural Sciences and a Master Media and Journalism. A decision I haven't come to regret!
A company hired me and they taught me the basics of VB.NET, WinForms and SQL Server.
 
At the end of that year I signed up for CodeProject and that was when my programming knowledge increased rapidly. Being around some of the best and most enthausiastic coders in the world certainly helps you develop your own skills.
 
After a while I enrolled in some IT courses at the Open University and I also got Microsoft Certified.
I am currently working to get a Bachelor degree in IT.
At my job I am programming in VB.NET, C# and SQL Server using WinForms and DevExpress controls.
 
Meanwhile I am trying to educate others through my (prize-winning) articles[^] here on CodeProject.

Comments and Discussions

 
GeneralFor great effect, you can combine this with other useful met... PinmemberJulien Villers15-Oct-11 2:00 
GeneralRe: Debugger.Break(), yeah. Use it from time to time when breakp... PinmemberNaerling15-Oct-11 2:06 

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
Web02 | 2.8.140916.1 | Last Updated 15 Oct 2011
Article Copyright 2011 by Sander Rossel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid