gpt4 book ai didi

c# - DEBUG 与 RELEASE 和分发程序集

转载 作者:太空狗 更新时间:2023-10-30 00:18:11 25 4
gpt4 key购买 nike

我正在创建和分发供其他开发人员使用的程序集。我正在分发我的程序集的发布版本(不是调试)。在我的程序集的一个类中,我将代码设置为仅在 Debug模式下使用

#if DEBUG
Console.WriteLine("Debug");
#else
Console.WriteLine("Release");
#endif

如果其他开发人员从他们的项目中引用我的程序集并在 Debug 模式下运行他们的项目,我的 Debug only 是否会条件运行?

最佳答案

If other developers reference my Assembly from their project and run their project in Debug mode, will my Debug only conditional run or not ?

不,因为 Console.WriteLine() 由于预处理器约束从未在 Release 模式下编译。

MSDN 对此有更多说法:

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 ... Tell me more...

此外,认为它已从程序集中删除是不正确的,因为它从来没有出现过。

关于c# - DEBUG 与 RELEASE 和分发程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41442036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com