想把“应用程序”做成“Windows Service”,不知合不合适,请大师指点。“应用程序”的情况:1、不论任何时候,应用程序随操作系统自动启动。 普通应用程序还要添加启动项,Windows Service不用添加了吧。2、寄宿“WCF”服务,被采集端和“Web”端使用。3、处理指定“数据库”数据,比如“回滚数据库数据”,“智能补充数据库数据”。4、预处理数据库数据,比如“排查错误”、“汇总计算”等。5、报警,“短信猫”通信。6、常用数据库维护,比如增、删、改、查“建筑信息”、“楼层信息”、“职工信息”、“人数信息”等。
这样的情况适合用“Windows Service”吗? 还是用传统“Winform”合适???
这样的情况适合用“Windows Service”吗? 还是用传统“Winform”合适???
Winform可能受杀毒软件的影响,“Windows Service”不受杀毒软件的影响吧。
没听说这么神奇,要不然写病毒的都用“Windows Service”好了。寄宿WCF服务,用Windows Server AppFabric这个现成的容器最好。
Windows Service受杀毒软件的影响更大
如果客户是广大小白,最好不要用Windows Service
如果是自己的服务器,最好用Windows Service
那就用Windows Service了
再写一些外围服务
比如,再写一个监测服务,如果你的主服务挂了,可以自动拉起
再写一个短信报警服务器,如果连续多次异常,短信报警
再写一个控制程序,用于与主服务交互
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[System.STAThread()]
static void Main()
{
try
{
System.Uri uri = new Uri(typeof(string).Assembly.CodeBase);
string RuntimePath = System.IO.Path.GetDirectoryName(uri.LocalPath);
string strInstallUtilPath = System.IO.Path.Combine(RuntimePath, "InstallUtil.exe");
foreach (string arg in System.Environment.GetCommandLineArgs())
{
Console.WriteLine(arg);
if (arg == "/install")
{
System.Diagnostics.Process.Start(strInstallUtilPath, "\"" + System.Windows.Forms.Application.ExecutablePath + "\"");
return;
}
else if (arg == "/uninstall")
{
System.Diagnostics.Process.Start(strInstallUtilPath, "/u \"" + System.Windows.Forms.Application.ExecutablePath + "\"");
return;
}
else if (arg == "/client")
{
// 启动客户端
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); using (frmClient frm = new frmClient())
{
Application.Run(frm);
//frm.ShowDialog();
Util.CloseDBConnection();
}
return;
}
else if (arg == "/debug")
{
MyFileSystemWatcherService service = new MyFileSystemWatcherService();
service.StartFileSystemWatching();
System.Threading.Thread.Sleep(1000 * 600);
return;
}
}
}
catch (Exception ext)
{
Console.WriteLine(ext.ToString());
return;
}
// 运行服务对象
ServiceBase.Run(new MyFileSystemWatcherService());
}
}怎么样在调试的时候,给应用程序添加“命令参数”???