问题描述
我有几个,这些在我的代码已工作的罚款,到目前为止:
I have several of these in my code which have been working fine so far:
#If DEBUG Then
... some code here
#End If
现在,我注意到,,最近,里面的代码#如果DEBUG然后...... #END如果
获取发布模式也执行。
Now, i am noticing that, lately, the code inside the " #If DEBUG Then ... #End If"gets execute also in "Release Mode".
这是奇怪的,之前并没有发生。什么可能发生,这样
在#if DEBUG现在被忽略(它们都在IDE或最终可执行调试被忽略)?
This is strange and did not happen before. What could have happened so thatthe #If DEBUG are now being ignored (they are ignored both in debug in the IDE or the final executable) ?
我已申请清洁,重建等:没有运气。感谢您的任何提示和帮助。
I have applied Clean, Rebuild, etc.: no luck. Thank you for any hints and help.
-PAM
推荐答案
首先,确保你明白你是如何运行的代码,以及如何你正在构建的区别吧。太多的人等同于调试版本和在调试器启动而不是与发行版,在调试器启动。他们是完全正交 - 你可以在调试器启动发布版本(一般可用较少的信息),你可以在调试器无法启动调试版本。道歉,如果你已经意识到了这一点。
Firstly, make sure you understand the difference between how you're running the code and how you're building it. Too many people equate "launching in a debugger" with "the debug version" and "launching not in a debugger" with "the release version". They're completely orthogonal - you can launch a release build in a debugger (typically with less information available) and you can launch a debug build not in a debugger. Apologies if you were already aware of this.
现在,假设你真的有无的改变你正在构建为Release项目配置,您需要检查项目属性为特定的配置。我不知道它是什么样子的VB,但在C#中的项目属性,在构建选项卡中,将有定义的符号列表 - 是的是影响是否#如果DEBUG
代码被编译或没有。 ?也许有人复制了项目配置从调试到发布
Now, assuming you really have changed the project configuration you're building to Release, you need to check the project properties for that specific configuration. I don't know what it looks like in VB, but in C# in the project properties, in the build tab, there will be a list of defined symbols - that is what affects whether #if DEBUG
code is built or not. Perhaps someone has copied over the project configuration from Debug into Release?
编辑:在建立一个检查方法的时间是:
#if DEBUG
#error This shouldn't happen
#endif
在发布版本,即应的建立没有错误。在调试,也不会
In a release build, that should build without error. In debug, it won't.
编辑:另一种选择是,你的整体的解的配置现在指的是错误的项目的配置类型。我不记得确切的菜单名称,但如果你看看周围项目配置管理器,你应该可以弹出一个网格映射工程和解决方案配置,以项目配置来构建。
Another option is that your overall solution configuration is now referring to the wrong project configuration types. I can't remember the exact menu name, but if you look around Project for Configuration Manager, you should be able to bring up a grid mapping "Project" and "Solution Configuration" to the project configuration to build.
这篇关于#如果DEBUG被忽略(VB.net或C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!