MScholtes/VirtualDesktop

Windows 11 exception when calling GetDesktops()

renil-joy opened this issue · 3 comments

Hi
Getting below exception in Windows 11 application, works fine in Windows 10. Using nuget package in a WPF application.
System.Collections.Generic.KeyNotFoundException: The given key 'IApplicationView' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.CreateAssembly()
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.GetAssembly()
at WindowsDesktop.VirtualDesktop.InitializeCore()
at WindowsDesktop.VirtualDesktop.InitializeIfNeeded()
at WindowsDesktop.VirtualDesktop.GetDesktops()

Any help will be much appreciated

If you're Windows 11 build (System > About > Windows specifications to find out) is above 22489 you should be using the Insider file

GetAllCurrentDesktops(); was added to IVirtualDesktopManagerInternal just before GetDesktops(IntPtr hWndOrMon, out IObjectArray desktops); on line 170

Thanks @aus10code. My bad, I was using this nuget, mistook this repo as name looked same. Found a fix in that repo.

Hello @renil-joy, hello @aus10code,

I renamed the files to reflect the new 21H2 version of Windows 11.

Greetings

Markus