爲什麼我啓動Windows窗體時,系統托盤中沒有顯示通知圖標?
這是我正在做的。
我有一個Windows服務,它啓動我的托盤應用程序,這是一個Windows窗體應用程序(我使用模擬在當前用戶的上下文中啓動該應用程序)。 在托盤應用程序中,我啓動了一個包含通知圖標的表單。
這裏的問題是,有時通知圖標不會出現在系統托盤中,我無法找出原因。
在窗體的OnLoad方法中,我將窗體的visible屬性設置爲false。 另外我正在做一些遠程服務調用(如ipc)。那是問題嗎?
如何讓我的通知圖標始終出現在系統托盤中?
編輯:這裏是的OnLoad功能
通知圖標未顯示在托盤C#winforms中
protected override void OnLoad(System.EventArgs e)
{
this.Visible = false;
//Get some value from registry
CheckForStealthMode();
GetLoginType();
bool GetProbeStatus = false;
ServiceActivityInterface remoteMethods = null;
do
{
try
{
remoteMethods = (ServiceActivityInterface)Activator.GetObject(typeof(ServiceActivityInterface), "tcp://localhost:18800/ServiceRemoting);
ProbeStatus = remoteMethods.GetProbeStatus();
GetProbeStatus = true;
}
catch (Exception exception)
{
GetProbeStatus = false;
log.Error("Exception while getting the status of Probe:" + exception.Message);
}
finally
{
remoteMethods = null;
if (!GetProbeStatus)
{
Thread.Sleep(5000);
log.Debug("Retrying to get the probe status.");
}
}
} while (!GetProbeStatus);
}
你可以在你的OnLoad方法中分享代碼嗎? –
只是托盤圖標沒有顯示出來,或者是其他任何操作都無法按預期運行?您是否檢查過Windows事件查看器,以查看應用程序事件日誌(甚至安全日誌)中是否有任何報告? –
@ Ben Scott我發佈了問題中的代碼。 – Prasad