编译器指令(DEBUG)在发布时出错

时间:2016-02-09 13:24:32

标签: c# wpf

我的WPF应用程序中有编译器指令的简单代码:

#if (DEBUG)
                MySettings.Default.Host = "http://localhost:63372/";
#else
                MySettings.Default.Host = "http://example.com/";
#endif

所有在Visual Studio中都可以正常工作。当我切换到Release或Debug时,Host填写正确。但是当我发布时,在反编译器中我看到Host等于"http://localhost:63372/"字符串。

哪里有问题?

info

2 个答案:

答案 0 :(得分:0)

你试过了吗?

#if (DEBUG)
                MySettings.Default.Host = "http://localhost:63372/";
#endif

#if (!DEBUG)
                MySettings.Default.Host = "http://example.com/";    
#endif

答案 1 :(得分:0)

我找到了anwser。使用clickOnce发布时,它使用当前选定的模式。因此,我需要切换到发布,然后单击发布。

相关问题