Hi all,
I am really stumped on this one so really appreciate any help.
I have a .net service which during OnStart creates a Process() to another .NET exe which I want to display a notify icon in the system tray and show a form. However the Main(string[] args) event in the exe is not firing even though the process is started (exe exists as process in Task Manager) All this code works from another Test exe but not the service. (Full Code Below).
Cheers
Stu
*****Service*****
protected override void OnStart(string[] args){
System.IO.
StreamWriter sw = new System.IO.StreamWriter(@"C:\CodeDir\KnowledgeAssist\KAClientManager\bin\Debug\Test1.txt", true);sw.WriteLine(
"0"); try{
Process notify = new Process();notify.StartInfo.FileName =
@"C:\CodeDir\KnowledgeAssist\KANotify\bin\Debug\KANotify.exe";notify.Start();
sw.WriteLine(
"1");}
catch(Exception ex){
sw.WriteLine(ex.Message);
}
sw.Close();
}
*****EXE*****
public static void Main(string[] args){
//new TrayIcon();System.IO.
StreamWriter sw = new System.IO.StreamWriter(@"C:\CodeDir\KnowledgeAssist\KAClientManager\bin\Debug\Test1.txt", true);sw.WriteLine(
"Main");sw.Close();
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());}
Sam HobbsPosted Mar 18, 2011, 2:45 AM
sanjib mukherjeePosted Mar 17, 2011, 7:26 AM
I have checked "allow to interact with desktop" check box in windows service properties.But Still some time the form is displaying and some time not but process gets generated.I can see in task bar.
Can anybody give me any idea why this is happening?
Additionally can anybody give me any idea about selecting the "allow to interact with desktop" check box from code?
Please help..
jalpa shahPosted Aug 1, 2008, 8:21 AM