"设计模式" preprocessor指令 [英] "Design Mode" preprocessor directive

查看:170
本文介绍了"设计模式" preprocessor指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个<一个href="http://social.msdn.microsoft.com/forums/en-us/winformsdesigner/thread/29383926-3DD1-4732-88A0-3148FD3F3B2D">problem上显示在设计一个组成部分。

I have a problem on displaying a component in Designer.

我认定的坏code,设计师不喜欢。

I identified the "bad" code that the designer does not like.

现在的问题是,仅在使用preprocessor指令,我不能注释它的设计时间。

Now, the problem is that I can't "comment" it for design time only using preprocessor directives.

现在,我试图(为VB.NET)以下

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?

推荐答案

您无法通过preprocessor实现这一目标。这是因为你可以运行调试的可执行文件之外VS(尝试一下,双击通过VS在调试模式中生成的EXE)。

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

不管怎样,有一个运行时(不是基于preprocessor)属性,可能会有所帮助:

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:

<一个href="http://msdn.microsoft.com/en-us/library/c58hb4bw(vs.71).aspx">http://msdn.microsoft.com/en-us/library/c58hb4bw(vs.71).aspx

<一个href="http://weblogs.asp.net/fmarguerie/archive/2005/03/23/395658.aspx">http://weblogs.asp.net/fmarguerie/archive/2005/03/23/395658.aspx

这篇关于&QUOT;设计模式&QUOT; preprocessor指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆