gpt4 book ai didi

c# - FolderBrowserDialog 使应用程序崩溃

转载 作者:行者123 更新时间:2023-12-04 16:33:37 24 4
gpt4 key购买 nike

每当我调用 folderbrowserdialog.showDialog() 时,我的应用程序就会崩溃。我使用的是之前对我有用的代码,所以它不能是代码。

try
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.RootFolder = Environment.SpecialFolder.Desktop;
if (fbd.ShowDialog() == DialogResult.OK)
{
// this.Minecraft.Text = fbd.SelectedPath;
}
}
catch
{
}

它没有抛出任何错误,没有异常,只是弹出了一个小加载圆圈,然后应用程序就消失了,我之前在另一个 .NET 应用程序中也注意到了它!

顺便说一句:重新安装 .net 4 可以吗?

最佳答案

尝试将其添加到您的应用程序中(最好是在 Main() 方法的开头)。查看exceptions.txt文件是否有任何异常记录到您到达冰点时。

        AppDomain.CurrentDomain.FirstChanceException += (sender, e) =>
{
if ((e == null) || (e.Exception == null))
{
return;
}

using (var sw = File.AppendText(@".\exceptions.txt"))
{
sw.WriteLine(e.ExceptionObject);
}
};

AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
if ((e == null) || (e.ExceptionObject == null))
{
return;
}

using (var sw = File.AppendText(@".\exceptions.txt"))
{
sw.WriteLine(e.ExceptionObject);
}
};

关于c# - FolderBrowserDialog 使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897076/

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