ookii-dialogs / ookii-dialogs-wpf

Awesome dialogs for Windows Desktop applications built with Microsoft .NET (WPF)
BSD 3-Clause "New" or "Revised" License
1.14k stars 85 forks source link

System.UnauthorizedAccessException when calling .ShowDialog #67

Closed ejohnson-dotnet closed 2 years ago

ejohnson-dotnet commented 2 years ago

When opening a TaskDialog, I am getting an exception of System.UnauthorizedAccessException.

Here is the exception and stack trace:

System.UnauthorizedAccessException: Access to the path 'C:\Users\username\AppData\Local\Temp\vkofhp5j.qjj' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITYATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Ookii.Dialogs.Wpf.ComCtlv6ActivationContext.EnsureActivateContextCreated() in //src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs:line 91 at Ookii.Dialogs.Wpf.ComCtlv6ActivationContext..ctor(Boolean enable) in //src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs:line 36 at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(IntPtr owner) in //src/Ookii.Dialogs.Wpf/TaskDialog.cs:line 1145 at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(Window owner) in /_/src/Ookii.Dialogs.Wpf/TaskDialog.cs:line 1095

augustoproiete commented 2 years ago

Looks like you might be running in a very restricted environment and need to change the permissions to allow your app to write files to your user's temp folder... Or possibly you have an antivirus running that is not trusting your app and blocking it from writing to the temp folder...

Unfortunately the API that creates the COM activation context requires a physical file path to read the app manifest, so your app must have the ability to write temporary files in order to use the Task Dialog...