Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conditional Compilation
Message
From
13/01/2009 03:46:23
 
 
To
13/01/2009 00:51:30
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01372770
Message ID:
01373096
Views:
32
>>>>>You can also test for debug mode
>>>>>
>>>>>if (System.Diagnostics.Debugger.IsAttached)
>>>>>{
>>>>>     DoSomething()
>>>>>}
>>>>>else
>>>>>{
>>>>>     DoSomethingElse()
>>>>>}
>>>>>
>>>>
>>>>I didn't know that. But now that I do I'm having trouble seeing a use for it.....

>>>
>>>
>>>I use that occasionally for error messages. IOW, an error message that gets displayed to the user at runtime might be an abbreviated version of the error message displayed to the developer during debugging.
>>
>>OK. But conditional compilation can do that. Using this it feels that I would be compiling/shipping surplus production code. i.e. if you're going to be around to debug it then why not just run a debug version.......
>
>I would also use conditional compilation over the if statement, I go as far as doing this for the design mode test:
>
>
>#if DEBUG
>if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
>#endif
>  {
>  ///Some code that I don't want in design mode.
>  }
>
Huh. That threw for a minute - then I worked out you were in WPF mode!. I'd probably just use this.IsInDesignMode (for readability)?
Are you doing much with WPF - it seems a while since anything has cropped up here under that category......
Regards,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform