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

Crash when calling VirtualDesktop.Current.Id on latest Windows 11 Insider build #74

Open
Slion opened this issue Apr 20, 2022 · 8 comments

Comments

@Slion
Copy link

Slion commented Apr 20, 2022

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:

@Slion
Copy link
Author

Slion commented Apr 20, 2022

Looks like some GUID for the API interfaces have changed.
See: MScholtes/VirtualDesktop@b17e545
From OS build 22489 and above apparently.

@Slion
Copy link
Author

Slion commented Apr 21, 2022

Looks like those guys fixed it already:
mntone#1

@Slion Slion changed the title Crash when calling VirtualDesktop.Current.Id on latest insider build Crash when calling VirtualDesktop.Current.Id on latest Windows 11 Insider build Apr 21, 2022
@Slion
Copy link
Author

Slion commented Apr 22, 2022

@Grabacr07 Any idea what could cause this? @NyaMisty says her fork is working on 22598 but it looks quite out dated.

@NyaMisty
Copy link

I mean my fork for MScholtes's are working.
They share same name, so don't be confused ;)

@NyaMisty
Copy link

Also, building this lib is quite easy, just build the test program to try out

@lenonk
Copy link

lenonk commented May 17, 2022

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:
image

@sliddington
Copy link

sliddington commented May 18, 2022

@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!).

@lenonk
Copy link

lenonk commented May 18, 2022

@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:

image

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

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

No branches or pull requests

4 participants