I try to open a browser in my Xamarin.Mac application like this
var url = getLaunchUrl(sessionId); try { Process.Start(url); } catch ( Exception ex) { // hack because of this: https://github.com/dotnet/corefx/issues/10361 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { url = url.Replace("&", "^&"); Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Process.Start("xdg-open", url); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Process.Start("open", url); } else { throw; } }
but nothing happens. Anything I'm doing wrong?
I think i got it. I need to url encode it before pass it to Process.Start
.
Answers
I test simply with
Process.Start("https://www.google.com");
on mac (Catalina), it works fine .Which platform did you test on ? Which is the OS version ?
Xamarin forums are migrating to a new home on Microsoft Q&A!
We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
For more information, please refer to this sticky post.
I'm on BigSur 11.1. Mono is 6.12.0.113. Exception i get is
Cannot find the specified file
.at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x000f6] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/mcs/class/System/System.Diagnostics/Process.cs:616
I think i got it. I need to url encode it before pass it to
Process.Start
.@martin_scholz Could you mark the answer if problem has been resolved ?