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

Tagged as

Preventing stubbed methods from being released

, 15 Oct 2011 CPOL
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

Sander Rossel is a professional developer with a working experience in .NET (VB and C#, WinForms, MVC, Entity Framework), JavaScript and SQL Server.

He has an interest in various technologies inlcuding, but not limited to, Functional Programming, NoSQL and Software Design.

He seeks to educate others on his blog, Sander's bits - Writing the code you need, and on his CodeProject profile.

Follow on   Twitter

Comments and Discussions

 
GeneralFor great effect, you can combine this with other useful met... PinmemberJulien Villers15-Oct-11 3:00 
GeneralRe: Debugger.Break(), yeah. Use it from time to time when breakp... PinmemberNaerling15-Oct-11 3: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 | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 15 Oct 2011
Article Copyright 2011 by Sander Rossel
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid