Why does Windows Service not launch external App?

前端 未结 2 598
抹茶落季
抹茶落季 2021-01-27 13:52

I am trying to get a Windows Service to launch an external application. When I start my service it doesn\'t load the application up.

There are no errors reported in the

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-27 14:11

    Enclose this code in try-catch and add a small trick which allows you to attach the debugger to the service. It is likely to be a permissions problem, but you will get it in the catch block

    protected override void OnStart(string[] args)
    {
        Debugger.Launch(); //displays a pop up window with debuggers selection
    
        try
        {
            App.StartInfo.FileName = @"C:\Program Files (x86)\SourceGear\DiffMerge\DiffMerge.exe";
            App.Start();
        }
        catch(Exception ex)
        {
            //see what's wrong here
        }    
    }
    

提交回复
热议问题