I have a problem on displaying a component in Designer.
I identified the "bad" code that the designer does not like.
Now, the problem is that I can't "comment" it for design time only using preprocessor directives.
Now, I tried (for VB.NET) the following
#If Not Debug Then
Private Sub myWpfComponent_ItsEvent(sender, args) Handles myWpfComponent.ItsEvent
...
#End If
this... worked, and now it is displayed without problems in the designer.
The problem now that I am afraid do not be able to debug properly this component.
So, I am searching for a workaround à la
#If Not DESIGN_TIME Then
#End If
Is there something similar?
There are 4 Main Types of Preprocessor Directives:Macros. File Inclusion. Conditional Compilation. Other directives.
Preprocessor directives are lines of the source file where the first non-whitespace character is # , which distinguishes them from other lines of text. The effect of each preprocessor directive is a change to the text and the result is a transformation of the text that does not contain the directives nor comments.
All Preprocessor directives begin with the # (hash) symbol. C++ compilers use the same C preprocessor. The preprocessor is a part of the compiler which performs preliminary operations (conditionally compiling code, including files etc...) to your code before the compiler sees it.
As the name justifies, preprocessor directives are a block of statements that gets processed before the actual compilation starts. C# preprocessor directives are the commands for the compiler that affects the compilation process.
You cannot achieve this through the preprocessor. This is because you can run a debug executable outside of VS (try it, double click on the EXE generated by VS under debug mode).
Anyway, there is a runtime (not preprocessor based) property that might help:
if (System.ComponentModel.LicenseManager.UsageMode ==
System.ComponentModel.LicenseUsageMode.Designtime)
These web pages will help and have other methods of checking for design mode at runtime:
http://msdn.microsoft.com/en-us/library/c58hb4bw(vs.71).aspx
http://weblogs.asp.net/fmarguerie/archive/2005/03/23/395658.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With