简体   繁体   English

C#:Release-Build-DL​​L中的Debug.Assert()似乎已由Debug-Build-Project激活

[英]C#: Debug.Assert() in Release-Build-DLL seems to be activated by Debug-Build-Project

I have an DLL with a lot of Debug.Assert() calls. 我有一个带有很多Debug.Assert()调用的DLL。 I have built this DLL as Release, so the Assert are not be active (I checked this with a small test programm). 我已经将此DLL构建为Release版本,因此Assert处于不活动状态(我通过一个小型测试程序进行了检查)。 Now I use this DLL in a software project which is a Debug-Build and for some reason the Asserts from the DLL are active again. 现在,我在调试(Debug-Build)软件项目中使用此DLL,由于某种原因,该DLL的断言再次处于活动状态。 Does the DEBUG definition of the project reactivate the asserts in the DLL? 项目的DEBUG定义是否会重新激活DLL中的断言? (VisualStudio 2013) (VisualStudio 2013)

The documentation states: 文档指出:

When the C# compiler encounters an #if directive, followed eventually by an #endif directive, it will compile the code between the directives only if the specified symbol is defined. 当C#编译器遇到#if指令,最后遇到#endif指令时,仅在定义了指定符号的情况下,编译器才会在指令之间编译代码。

Considering this I would say you should not see these asserts, because when compiling in Release mode the code should have been left out. 考虑到这一点,我会说您不应看到这些断言,因为在“发布”模式下进行编译时,应将代码省去。

You could try to decompile your release assembly and see if the code was generated. 您可以尝试反编译发布程序集,并查看代码是否已生成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM