OpenFolderDialog crashing application
See original GitHub issueI keep getting an exception thrown at this location when attempting to execute .ShowAsync() on a FolderOpenDialog. Here is a summary of my code:
private OpenFolderDialog dialog_Source; // Field
{
dialog_Source = new OpenFolderDialog();
dialog_Source.Title = "Select User Folder";
var path = await dialog_Source.ShowAsync(this);
}
Runs fine on Win10 x64, and macOS Big Sur (even in Recovery Mode), but I cannot get this to run in Windows PE. I have run other .NET Core apps fine in this environment, so I know it should be possible. Running this as a self-contained deployment so it should have all the dependencies. Any ideas?
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Avalonia.Win32.SystemDialogImpl.<>c__DisplayClass2_0.<ShowFolderDialogAsync>b__0() in /_/src/Windows/Avalonia.Win32/SystemDialogImpl.cs:line 112
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at UserBackup.MainWindow.click_button_Source(Object sender, RoutedEventArgs e) in ....MainWindow.axaml.cs:line 87
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
c# - FolderBrowserDialog crashes the application
showDialog() my application crashes. I'm using the code that worked before for me, so it CAN NOT be the code. try { FolderBrowserDialog...
Read more >Open the file dialog box causes a crash #3028
If I leave the FolderBrowserDialog open for longer then 20 seconds or so, it crashes my app. There is no exception.
Read more >Unable to access files and applications, and apps are also ...
I understand it can be frustrating when the apps are crashing, and folders and files are not accessible after updates. As you have...
Read more >VS 2019 RC.2 and VS 2017 15.9.9 crashes when an ...
Everytime I use any kind of command which lets me select a file (e.g. "Open solution", "Add existing project", "Add reference" and more), ......
Read more >OpenFileDialog sometimes crashes
Using SkinFramework v11.2.2 ocx in my application, OpenFileDialog sometimes crashes directly after opening. Also, the address bar and search ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@imerzan Yeah, I don’t disagree there. That UI is provided by Avalonia itself, and well…I’ve tried to improve it a bit since the 0.10.x releases, but I’m not sure those improvements would be enough for your use case…
…BitLocker whatnow? Yeah I fear that’s…likely beyond my capabilities, unfortunately :C
Not sure if that’s a thing you can do, nor how, but…best of luck in your search. Hopefully someone else here will have a more…satisfactory answer/solution to offer.
@imerzan It’s a feature within Avalonia - there’s an extension method called
UseManagedSystemDialogs()
in theAvalonia.Dialogs
namespace. Just add that to your AppBuilder.(You’ll find that in the form of the
BuildAvaloniaApp()
function inProgram.cs
, unless you’ve moved it or something)Side note: Loosely speaking,Microsoft.Win32.FolderBrowserDialog
is more or less the opposite of the managed system dialogs.Also, I should probably clarify: although this may allow you to band-aid your way around the initial problem, I’m not entirely certain whether that initial problem is expected under WinPE or a bug of some sort…