Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows.ApplicationModel does not exist, why?

Tags:

uwp

I met an UWP issue, and asked question as below post: How to detect user idle in UWP?

Thanks for Nico to answer my question! And he provided an example code here: https://stefanwick.com/2018/05/15/global-hotkey-registration-in-uwp/ https://github.com/StefanWickDev/ExtensionGallery/tree/master/GlobalHotkey

Some of the codes which report compile errors are:

using Windows.ApplicationModel;
using Windows.ApplicationModel.AppService;
using Windows.ApplicationModel.Core;
using Windows.Foundation.Collections;
using Windows.Storage;

But I cannot run the above code, I mean the GlobalHotkey project. I got 18 compile errors as below picture shown. enter image description here

The first error is:

The type or namespace name 'ApplicationModel' does not exist in the namespace 'Windows'

I cannot find Windows.ApplicationModel by this way:

Project -> Right Click -> Add -> Reference -> Assemblies -> Search "System.Drawing"

Like this picture shown: enter image description here

And I did not change the code at all. I also install the SDK Build 17134, which is required by the original code. Why?

More: To answer Pavel Anikhouski's question, please check below picture. I have the two files, and no items under Universal Windows subtree. enter image description here

like image 924
Tom Xue Avatar asked Oct 14 '25 22:10

Tom Xue


1 Answers

Windows.ApplicationModel does not exist, why?

The problem is you have missed Windows.winmd reference for Desktop App. You could find it with this path C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.xxxxxx.0\Windows.winmd for more please refer this case reply.

If your project has missed Windows Desktop Extension for UWP lib, Please install windows sdk and search it in extension list as you mentioned.

like image 112
Nico Zhu - MSFT Avatar answered Oct 18 '25 00:10

Nico Zhu - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!