预编译命令 #if DEBUG

2023-03-07,,

在控制台程序根据预编命令

http://www.askapache.com/windows/advanced-batch-scripting.html

namespace SXGYCarTransfrom.Handle
{
class Program
{
static void Main(string[] args)
{
#if DEBUG
RunAsConsole();
#else
RunAsServer();
#endif
} /// <summary>
/// DEBUG 时跑的为控制台程序
/// </summary>
private static void RunAsConsole()
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(TaskStart.CurrentDomain_UnhandledException);
var _task = new TaskStart();
while (true)
{
// 输出日志
Console.ReadLine();
}
} /// <summary>
/// Release 时启动的为服务
/// </summary>
private static void RunAsServer()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new TransService()
};
ServiceBase.Run(ServicesToRun);
}
}
}

预编译命令 #if DEBUG的相关教程结束。

《预编译命令 #if DEBUG.doc》

下载本文的Word格式文档,以方便收藏与打印。