Windows.ApplicationModel 不存在,为什么? [英] Windows.ApplicationModel does not exist, why?

查看:40
本文介绍了Windows.ApplicationModel 不存在,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个 UWP 问题,并提出了如下问题:

第一个错误是:

<块引用>

命名空间Windows"中不存在类型或命名空间名称ApplicationModel"

我无法通过这种方式找到 Windows.ApplicationModel:

<块引用>

项目 -> 右键单击​​ -> 添加 -> 引用 -> 程序集 -> 搜索系统.绘图"

像这张图所示:

而且我根本没有更改代码.我还安装了原始代码所需的SDK Build 17134.为什么?

更多:要回答 Pavel Anikhouski 的问题,请查看下图.我有这两个文件,通用 Windows 子树下没有任何项目.

解决方案

Windows.ApplicationModel 不存在,为什么?

问题是您错过了桌面应用程序的 Windows.winmd 参考.你可以通过这个路径找到它 C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.xxxxxx.0\Windows.winmd 更多请参考这个案例 回复.

如果您的项目缺少 Windows Desktop Extension for UWP 库,请安装 windows sdk 并在您提到的扩展列表中搜索它.

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.

解决方案

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.

这篇关于Windows.ApplicationModel 不存在,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆