1
我使用Google搜索this one自我安裝的WInService
但是當我試圖應用它時,我得到一個錯誤。所以安裝/卸載工作正常,但服務本身不啓動,並在超時後說服務沒有響應。我不知道爲什麼。當我附加處理它甚至不進入Main()方法,靜態構造函數等等。我已使用this addon進行附加。
public static void Main()
{
AppDomain.CurrentDomain.UnhandledException += OnException;
if (Environment.UserInteractive)
{
AskUserForInstall();
}
else
{
ServiceBase.Run(new NotificatorService());
}
}
服務也很簡單:
using System.ServiceProcess;
using System.Windows;
namespace AZNotificator
{
public partial class NotificatorService : ServiceBase
{
static NotificatorService()
{
int x = 5;
}
public NotificatorService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
MessageBox.Show("Hello");
}
protected override void OnStop()
{
}
}
}