gpt4 book ai didi

c# - #if DEBUG 不适用于 Windows 服务发布版本

转载 作者:太空宇宙 更新时间:2023-11-03 18:04:16 25 4
gpt4 key购买 nike

在我的 Windows 服务的构造函数中,我在 #if DEBUG 条件中有一些代码:

#if DEBUG
var container = CompositionRoot.DiBootstrapper.Initialize();
_initializeApplication = container.Resolve<IInitializeApplication>();
_initializeApplication.Initialize();
#endif

当我在 Release模式下编译/构建项目并将其安装为 Windows 服务时,执行 #if DEBUG 条件中的代码。

我只希望代码在调试应用程序时运行。

有什么建议吗?

最佳答案

确保“DEBUG”常量未在 Release 模式下定义。

enter image description here

另外,当解决方案处于 Release模式时,验证您的项目是否设置为在 Release模式下构建。

enter image description here

关于c# - #if DEBUG 不适用于 Windows 服务发布版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39018000/

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