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

Open and save file dialog crash on Windows 7 ( maybe duplicate #1700 but still issue) #3272

Closed
Sorcon opened this issue Nov 18, 2019 · 7 comments · Fixed by #7028
Closed

Comments

@Sorcon
Copy link

Sorcon commented Nov 18, 2019

System.ArgumentException
  HResult=0x80070057
  Сообщение = Value does not fall within the expected range.
  Источник = Avalonia.Win32
  Трассировка стека:
   at Avalonia.Win32.Interop.UnmanagedMethods.IShellItem.GetDisplayName(UInt32 sigdnName, IntPtr& ppszName)
   at Avalonia.Win32.SystemDialogImpl.GetAbsoluteFilePath(IShellItem shellItem)
   at Avalonia.Win32.SystemDialogImpl.<>c__DisplayClass1_0.<ShowFileDialogAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Avalonia.Controls.SaveFileDialog.<ShowAsync>d__4.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at <**>.ViewModels.<**>ReportViewModel.<SaveFileAsync>d__11.MoveNext() in <**>\ViewModels\<**>ReportViewModel.cs

Avalonia version 0.8.1

@Sorcon
Copy link
Author

Sorcon commented Nov 18, 2019

Reproduces with save file to Windows Library folders (Documents, Music, etc)

@Gillibald
Copy link
Contributor

Could you test this against the 0.9 preview?

@Gillibald
Copy link
Contributor

Will close this because of no response. Let us know if you want to have another look.

@mat1jaczyyy
Copy link
Contributor

Still hitting this @Gillibald testing against latest cibuild as of writing this

Apollo Version: Version 1.3.1
Operating System: Microsoft Windows 6.1.7601 Service Pack 1

System.ArgumentException: Value does not fall within the expected range.
   at Avalonia.Win32.Interop.UnmanagedMethods.IShellItem.GetDisplayName(UInt32 sigdnName, IntPtr& ppszName)
   at Avalonia.Win32.SystemDialogImpl.GetAbsoluteFilePath(IShellItem shellItem)
   at Avalonia.Win32.SystemDialogImpl.<>c__DisplayClass1_0.<ShowFileDialogAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   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 where exception was thrown ---
   at Avalonia.Controls.SaveFileDialog.ShowAsync(Window parent)
   at Apollo.Elements.Project.Save(Window sender, Boolean store) in C:\Users\mat1jaczyyy\Desktop\apollo-studio\Apollo\Elements\Project.cs:line 175
   at Apollo.Elements.Project.Save(Window sender) in C:\Users\mat1jaczyyy\Desktop\apollo-studio\Apollo\Elements\Project.cs:line 153
   at Apollo.Components.SaveButton.Click(PointerReleasedEventArgs e) in C:\Users\mat1jaczyyy\Desktop\apollo-studio\Apollo\Components\SaveButton.cs:line 51
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
   at Avalonia.Threading.AvaloniaSynchronizationContext.<>c__DisplayClass5_0.<Post>b__0()
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority)
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode)
   at Apollo.Core.Program.Main(String[] args) in C:\Users\mat1jaczyyy\Desktop\apollo-studio\Apollo\Core\Program.cs:line 125

Repros on Windows 7. Have not tested 8. Does not repro on Windows 10.

Works as intended if the path to the file is short, as soon as I cross roughly 250 characters total path length, I get this crash. Just keep making folders in folders, it should repro eventually on W7.

Sounds like a dupe of #1700, but with additional repro cases (that issue was for all paths). Now the OP here is using Libraries to crash it, and I got a repro with long path.

@wieslawsoltes
Copy link
Collaborator

if (shellItem.GetDisplayName(UnmanagedMethods.SIGDN_FILESYSPATH, out pszString) == (uint)UnmanagedMethods.HRESULT.S_OK)

uint GetDisplayName([In] uint sigdnName, out IntPtr ppszName);

https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishellitem-getdisplayname

HRESULT GetDisplayName(
  SIGDN  sigdnName,
  LPWSTR *ppszName
);

maybe this would help?

uint GetDisplayName([In] uint sigdnName, [Out, MarshalAs(UnmanagedType.LPWStr)] out IntPtr ppszName);

I am also getting this exception using latest master:

Unhandled exception. System.ArgumentException: Value does not fall within the expected range.
   at Avalonia.Win32.Interop.UnmanagedMethods.IShellItem.GetDisplayName(UInt32 sigdnName, IntPtr& ppszName)
   at Avalonia.Win32.SystemDialogImpl.GetAbsoluteFilePath(IShellItem shellItem)
   at Avalonia.Win32.SystemDialogImpl.<>c__DisplayClass1_0.<ShowFileDialogAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   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 where exception was thrown ---
   at Core2D.UI.Editor.AvaloniaProjectEditorPlatform.OnOpen(String path) in D:\a\Core2D\Core2D\src\Core2D\UI\Editor\AvaloniaProjectEditorPlatform.cs:line 40
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
   at Avalonia.Threading.AvaloniaSynchronizationContext.<>c__DisplayClass5_0.<Post>b__0()
   at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run()
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority)
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode)
   at Core2D.Program.Main(String[] args) in D:\a\Core2D\Core2D\src\Core2D\Program.cs:line 22

@wberdowski
Copy link

Please fix.

@stakira
Copy link

stakira commented Nov 7, 2021

End user reported the same issue. Verified that it is on Windows 7:
Avalonia 0.10.8

System.ArgumentException: Value does not fall within the expected range.
   at Avalonia.Win32.Interop.UnmanagedMethods.IShellItem.GetDisplayName(UInt32 sigdnName, IntPtr& ppszName)
   at Avalonia.Win32.SystemDialogImpl.GetAbsoluteFilePath(IShellItem shellItem) in /_/src/Windows/Avalonia.Win32/SystemDialogImpl.cs:line 153
   at Avalonia.Win32.SystemDialogImpl.<>c__DisplayClass1_0.<ShowFileDialogAsync>b__0() in /_/src/Windows/Avalonia.Win32/SystemDialogImpl.cs:line 90
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   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 where exception was thrown ---
   at Avalonia.Controls.SaveFileDialog.ShowAsync(Window parent) in /_/src/Avalonia.Controls/SystemDialog.cs:line 34
   at OpenUtau.App.Views.MainWindow.SaveAs() in C:\projects\openutau\OpenUtau\Views\MainWindow.axaml.cs:line 148
   at OpenUtau.App.Views.MainWindow.OnMenuSaveAs(Object sender, RoutedEventArgs args) in C:\projects\openutau\OpenUtau\Views\MainWindow.axaml.cs:line 136
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
   at Avalonia.Threading.AvaloniaSynchronizationContext.<>c__DisplayClass5_0.<Post>b__0() in /_/src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs:line 33
   at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run() in /_/src/Avalonia.Base/Threading/JobRunner.cs:line 178
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in /_/src/Avalonia.Base/Threading/JobRunner.cs:line 37
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/Win32Platform.cs:line 254
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) in /_/src/Windows/Avalonia.Win32/Win32Platform.cs:line 198
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 62
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 127
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 175
   at OpenUtau.App.Program.Run(String[] args) in C:\projects\openutau\OpenUtau\Program.cs:line 38
   at OpenUtau.App.Program.Main(String[] args) in C:\projects\openutau\OpenUtau\Program.cs:line 21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants