gpt4 book ai didi

c# - .Net Core 3.1 Process.Start ("www.website.com") 在 WPF 中不起作用

转载 作者:行者123 更新时间:2023-12-01 09:41:37 24 4
gpt4 key购买 nike

我在 WPF 应用程序中使用 .Net Core 3.1 框架。我有一个按钮事件,我试图在点击时重定向到 Instagram 网址。但它给了我以下错误。

Exception thrown: 'System.ComponentModel.Win32Exception' in System.Diagnostics.Process.dll.


private void Insta_Click(object sender, RoutedEventArgs e)
{
try
{
string targetURL = "https://www.instagram.com/xyz/";
Process.Start(targetURL);
}
catch
{
}
}

最佳答案

您必须根据以下内容更改代码

var targetURL = "https://www.instagram.com/xyz/";
var psi = new ProcessStartInfo
{
FileName = targetURL,
UseShellExecute = true
};
Process.Start(psi);

UseShellExecute 属性设置为 false默认在 .NET Core 中,打开 https://链接您必须将其设置为 true ,因为它不是可执行文件

关于c# - .Net Core 3.1 Process.Start ("www.website.com") 在 WPF 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59716856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com