Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 编译器指令(调试)在发布时工作错误_C#_Wpf - Fatal编程技术网

C# 编译器指令(调试)在发布时工作错误

C# 编译器指令(调试)在发布时工作错误,c#,wpf,C#,Wpf,我的WPF应用程序中有带编译器指令的简单代码: #if (DEBUG) MySettings.Default.Host = "http://localhost:63372/"; #else MySettings.Default.Host = "http://example.com/"; #endif 在VisualStudio中,所有工作都很好。当我切换到Release或Debug时,主机已正确填充。但是当我发布时,在反编译器中我

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

#if (DEBUG)
                MySettings.Default.Host = "http://localhost:63372/";
#else
                MySettings.Default.Host = "http://example.com/";
#endif
在VisualStudio中,所有工作都很好。当我切换到Release或Debug时,主机
已正确填充。但是当我发布时,在反编译器中我看到
Host
等于
”http://localhost:63372/“
string

哪里有问题

您是否尝试过:

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

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

我已经找到了答案。使用clickOnce发布时,它使用当前选定的模式。所以,我需要切换到release,然后单击Publish。

你发布得怎么样?@CodingGorilla:忘了提了。我按逻辑使用ClickOnce,这与OP当前的操作完全相同。