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

11.1.0-rc1. TrayIcon is not working on Windows 7. Unable to load DLL 'shcore.dll' or one of its dependencies. #16146

Closed
evgeniylevakhin opened this issue Jun 26, 2024 · 1 comment · Fixed by #16148

Comments

@evgeniylevakhin
Copy link
Contributor

Describe the bug

TrayIcon stopped working after upgrading from 11.0.10 to 11.1.0-rc1 on Windows 7 [Version 6.1.7601]

2024-06-26 14:01:32.749 -05:00 [FTL] [737508C3] App Unhandled error occured
System.DllNotFoundException: Unable to load DLL 'shcore.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
   at Avalonia.Win32.Interop.UnmanagedMethods.GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, UInt32& dpiX, UInt32& dpiY)
   at Avalonia.Win32.TrayIconImpl.UpdateIcon(Boolean remove)
   at Avalonia.Win32.TrayIconImpl.SetIcon(IWindowIconImpl icon)
   at Avalonia.Controls.TrayIcon.OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
   at Avalonia.AvaloniaObject.OnPropertyChangedCore(AvaloniaPropertyChangedEventArgs change)
   at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaProperty`1 property, Optional`1 oldValue, BindingValue`1 newValue, BindingPriority priority, Boolean isEffectiveValue)
   at Avalonia.PropertyStore.EffectiveValue`1.SetAndRaiseCore(ValueStore owner, StyledProperty`1 property, T value, BindingPriority priority, Boolean isOverriddenCurrentValue, Boolean isCoercedDefaultValue)
   at Avalonia.PropertyStore.EffectiveValue`1.SetLocalValueAndRaise(ValueStore owner, StyledProperty`1 property, T value)
   at Avalonia.PropertyStore.ValueStore.SetLocalValue[T](StyledProperty`1 property, T value)
   at Avalonia.PropertyStore.ValueStore.SetValue[T](StyledProperty`1 property, T value, BindingPriority priority)
   at Avalonia.AvaloniaObject.SetValue[T](StyledProperty`1 property, T value, BindingPriority priority)
   at Avalonia.Controls.TrayIcon.set_Icon(WindowIcon value)

It appears that Win32.TrayIconImpl is missing some platform checks:

if ((HRESULT)GetDpiForMonitor(s_taskBarMonitor, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out var dpiX, out var dpiY) == HRESULT.S_OK)

E.g.:

if (UnmanagedMethods.ShCoreAvailable && Win32Platform.WindowsVersion > PlatformConstants.Windows8)

Is this a bug or there are no plans to add this?

To Reproduce

A minimal project with TrayIcon.

Expected behavior

No response

Avalonia version

11.1.0-rc1

OS

Windows

Additional context

No response

@thevortexcloud
Copy link
Contributor

Avalonia does not officially support Windows 7. But fixes from the community are generally accepted as long as they have a low chance of breaking other things.

https://docs.avaloniaui.net/docs/faq#what-versions-of-windows-are-supported

evgeniylevakhin pushed a commit to evgeniylevakhin/Avalonia that referenced this issue Jun 27, 2024
github-merge-queue bot pushed a commit that referenced this issue Jun 28, 2024
#16146

Co-authored-by: evgeniy <[email protected]>
Co-authored-by: Max Katz <[email protected]>
maxkatz6 added a commit that referenced this issue Jun 28, 2024
#16146

Co-authored-by: evgeniy <[email protected]>
Co-authored-by: Max Katz <[email protected]>
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.

3 participants