question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenFolderDialog crashing application

See original GitHub issue

https://github.com/AvaloniaUI/Avalonia/blob/9dbcc98a8709d8b185f6f0dc69df19e6873cb97c/src/Windows/Avalonia.Win32/SystemDialogImpl.cs#L112

I 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Splitwirezcommented, Jul 30, 2021

@Splitwirez OK, I was able to get that to build.

Runs in WinPE, and the folder open dialog opens without any issues, but it appears to be a really archaic interface that doesn’t have much functionality.

@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…

Trying to get the updated Win7/10 interface since it allows for click-to-unlock on Bitlocker Locked Drives where it automatically prompts for a Bitlocker Recovery Key. The Managed Dialog doesn’t appear to have it.

…BitLocker whatnow? Yeah I fear that’s…likely beyond my capabilities, unfortunately :C

I’m guessing WinPE is missing a system dependency of some sort for the Avalonia Interface, not sure how I could maybe pack it in with my self-contained app.

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.

1reaction
Splitwirezcommented, Jul 30, 2021

@Splitwirez I can check. Is this implemented within Avalonia or do you mean checking Microsoft.Win32.OpenDileDialog ?

@imerzan It’s a feature within Avalonia - there’s an extension method called UseManagedSystemDialogs() in the Avalonia.Dialogs namespace. Just add that to your AppBuilder.

(You’ll find that in the form of the BuildAvaloniaApp() function in Program.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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found