相关疑难解决方法(0)

#if debug - > #if myOwnConfig?

在c#中有一种方法可以使用像"#if DEBUG"这样的自定义配置

我需要一个"#if OFFLINE",因为我的Build-Config名称是"离线"(仅用于进一步的调试目的)...

谢谢!

c# debugging buildconfig visual-studio buildconfiguration

67
推荐指数
3
解决办法
2万
查看次数

可以在Release中构建后执行#if DEBUG吗?

正在进行安全性讨论,以确定下面的以下DEPLOYED代码是否可以到达或"提升"到......即使它是在RELEASE模式下构建的.

思考?

编辑:
我在DotPeek中"看到"它 - 即使在发布后构建.

  • 但是,该文件是"灰显的"

  • 这是否意味着它不会执行?

  • DotPeek只是"反编译"代码......它没有显示它内置的模式中存在什么代码......对吗?

代码看起来像:

    using System;
    using System.ServiceProcess;

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
#if DEBUG
            var myservice = new StpListener();
            myservice.OnDebug();

            //KEEP the service alive
            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
            { 
                new StpListener() 
            };
            ServiceBase.Run(ServicesToRun);
#endif
        }
    } 
Run Code Online (Sandbox Code Playgroud)

c#

3
推荐指数
2
解决办法
249
查看次数