VirtualDesktop
VirtualDesktop copied to clipboard
Crash when calling VirtualDesktop.Current.Id on latest Windows 11 Insider build
After upgrading my Windows 11 installation to the insider build below I get the following exception:
Edition Windows 11 Pro Version 22H2 OS build 22598.200 Experience Windows Feature Experience Pack 1000.22598.200.0
System.Collections.Generic.KeyNotFoundException
HResult=0x80131577
Message=The given key 'IApplicationView' was not present in the dictionary.
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.CreateAssembly()
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.GetAssembly()
at WindowsDesktop.VirtualDesktop.InitializeCore()
at WindowsDesktop.VirtualDesktop.InitializeIfNeeded()
at WindowsDesktop.VirtualDesktop.get_Current()
Related issues:
- https://github.com/MScholtes/VirtualDesktop/issues/35
- https://github.com/mntone/VirtualDesktop/pull/1
Looks like some GUID for the API interfaces have changed. See: https://github.com/MScholtes/VirtualDesktop/commit/b17e5454776e174f3feea613ecb1abc0d5ff180e From OS build 22489 and above apparently.
Looks like those guys fixed it already: https://github.com/mntone/VirtualDesktop/pull/1
@Grabacr07 Any idea what could cause this? @NyaMisty says her fork is working on 22598 but it looks quite out dated.
I mean my fork for MScholtes's are working. They share same name, so don't be confused ;)
Also, building this lib is quite easy, just build the test program to try out
I'm fairly new to C#, and I'm having the same problem on the latest dev build of Windows 11. I've done some projects before in C#, but I have a less than ideal understanding of dependencies and how to use/modify them when they don't "just work" straight out of NuGet. I'm more of C/C++ on Linux guy.
Can someone help me out and explain (like I'm 5) the best way to get this working? I'm trying to write a little gui app to make Windows' virtual desktop management fit better with my own workflow.
Edit: For clarity, here's the line of code throwing the exception for me:
var desktops = VirtualDesktop.GetDesktops();
And here's the error:
@lenonk you would need to download the source tree from one of those branches and add the project to your solution and add references where needed (instead of just using nuget). Then build and see if it works. I too ran into such things and it seems that for some versions the registry does not contain the interface names and so I tried adding them hard-coded - unfortunately I never checked it into github only my sourceforge repo - https://sourceforge.net/p/virtual-desktop-grid-switcher/src/ci/a2766ed8b60e1e5b13bcd588ecfc934e923b4034/. Unfortunately I never managed to get my repo working on both standard win 11 and insider previews which seem to have different APIs .. grrr! I will get around to merging the official version of this library which apparently works on standard win 11 and mine at some point and fingers crossed it works on both ... trouble is I don't have access to a machine on both versions.
BTW, if you are from Linux you may find my program does what you want - I went from Linux (in the 90s) to VirtuaWin on windows and wrote this to be similar when Windows 10 came out and had native desktops (which seem stupid to anyone who has ever used them elsewhere because there are major things "missing" like a key combo to move a window to a different desktop - oh and yes 12 desktops in one single row is really usable - not! Windows developers seem to think everybody loves using their mouse for everything!).
@sliddington Thanks for the info. I'm still not sure I can get it done, but I'll try. Also, I don't even know if it will help me, as I just realized I'm running:
Also, this is what I'm looking for. I don't use it so much for switching between desktops, but as an indicator of what desktop I'm on, and creating new desktops. It's just a really convenient widget, and one I've realized I can't really live without. I can't find anything like it on Windows, so I'm writing it. shrug. I would probably do better to just do it in C++. I still wouldn't really understand the Windows interfaces, but at least I'd be more familiar with the language.
https://github.com/wsdfhjxc/virtual-desktop-bar