Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.ArgumentNullException in ComCtlv6ActivationContext #32

Closed
mgpreston opened this issue Dec 1, 2020 · 4 comments · Fixed by #33
Closed

System.ArgumentNullException in ComCtlv6ActivationContext #32

mgpreston opened this issue Dec 1, 2020 · 4 comments · Fixed by #33
Labels
bug Something isn't working
Milestone

Comments

@mgpreston
Copy link

I'm encountering the following error when running as a self-contained .NET 5 single-file bundle:

System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.IO.Path.Combine(String path1, String path2)
at Ookii.Dialogs.Wpf.ComCtlv6ActivationContext.EnsureActivateContextCreated()
at Ookii.Dialogs.Wpf.ComCtlv6ActivationContext..ctor(Boolean enable)
at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(IntPtr owner)
at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(Window owner)

The code that's responsible just looks like this:

var dialog = new VistaFolderBrowserDialog();
dialog.ShowDialog(Application.Current.MainWindow);

It looks like the ComCtlv6ActivationContext.EnsureActivateContextCreated method doesn't expect assemblyLoc to be an empty string, which it can be when running as a self-contained single-file bundle (see Remarks of Assembly.Location docs):
https://github.com/augustoproiete/ookii-dialogs-wpf/blob/2a64fea6c5c3d32f468814d205a337ce78afedab/src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs#L70-L79

The Path.GetDirectoryName method returns null when passed an empty string (even though the docs for it suggest an ArgumentException instead).

I guess this will no longer be a problem when issue #31 is implemented, but thought it worth mentioning as there doesn't seem to be an easy workaround.

@augustoproiete augustoproiete added the bug Something isn't working label Dec 1, 2020
@augustoproiete
Copy link
Member

Thanks for reporting this @mgpreston!

You're correct: This won't be an issue when #31 is implemented, but the fact that self-contained .NET 5 single-file apps are breaking raises the priority for implementing it.

I'll get a release out tonight that fixes this issue.

@augustoproiete
Copy link
Member

@mgpreston I've just published Ookii.Dialogs.Wpf v3.1.0 on nuget.org which fixes this

@mgpreston
Copy link
Author

@augustoproiete Thanks for fixing this so quickly. I'm happy to report that it's working perfectly now!

@augustoproiete
Copy link
Member

@mgpreston You're welcome! Thanks for confirming it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants