harlam357 / hfm-net

Client Monitoring Application for Folding@Home
34 stars 6 forks source link

Error opening web page links in .NET 5 version #353

Closed firedfly closed 2 years ago

firedfly commented 2 years ago

When running the new .NET 5 version of HFM (v9.25.1650), none of the links to web pages will open (e.g. HFM Google Group; FAH User Stats Page, etc). These menu items work correctly in the .NET Framework build of v9.25.1650 on the same computer.

The following error displays on screen: image

The follow is recorded in the HFM log file:

[8/22/2021-7:44:55 PM] X The system cannot find the file specified.
[8/22/2021-7:44:55 PM] X System.ComponentModel.Win32Exception (2): The system cannot find the file specified.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName)
   at HFM.Core.Services.DefaultLocalProcess.Start(String fileName)
   at HFM.Core.Services.DefaultLocalProcessService.Start(String fileName)
   at HFM.Forms.Internal.LocalProcessServiceExtensions.StartAndNotifyError(LocalProcessService localProcess, String fileName, String errorMessage, ILogger logger, MessageBoxPresenter messageBox)
firedfly commented 2 years ago

It looks like starting the process with UseShellExecute=true will fix the issue. I'm not familiar enough with the code to know if changing that will have any side effects elsewhere, though.

It looks like the default value for this property changed from .net framework to .net core: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.useshellexecute?view=netframework-4.8

I tested changing the property by updating one of the start methods in DefaultLocalProcess to:

public static DefaultLocalProcess Start(string fileName)
        {
            var startInfo = new ProcessStartInfo(fileName) { UseShellExecute = true };
            return new DefaultLocalProcess(Process.Start(startInfo));
        }
harlam357 commented 2 years ago

Found the same info. Fixed in latest commit. Thanks @firedfly for the help and the PRs! Keep them coming!