Windows.ApplicationModel does not exist, why?

柔情痞子 提交于 2021-02-11 13:33:03

问题


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.

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:

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.


回答1:


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.



来源:https://stackoverflow.com/questions/59067770/windows-applicationmodel-does-not-exist-why

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!