Click here to Skip to main content
12,756,437 members (33,042 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

4.1K views
1 bookmarked
Posted 14 Oct 2011

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. :)

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), HTML, CSS, JavaScript, Oracle and SQL Server.

He has an interest in various technologies including, but not limited to, Functional Programming, NoSQL, Software Design, Continuous Integration and, more generally, Software Quality.

He wrote two ebooks which you can download for free: Object-Oriented Programming in C# Succinctly and SQL Server for C# Developers Succinctly

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

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralFor great effect, you can combine this with other useful met... Pin
Julien Villers15-Oct-11 3:00
memberJulien Villers15-Oct-11 3:00 
GeneralRe: Debugger.Break(), yeah. Use it from time to time when breakp... Pin
Naerling15-Oct-11 3:06
memberNaerling15-Oct-11 3:06 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170217.1 | Last Updated 15 Oct 2011
Article Copyright 2011 by Sander Rossel
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid