繁体   English   中英

Visual Studio 2015 - C#Windows Universal App缺少程序集引用

[英]Visual Studio 2015 - C# Windows Universal App missing assembly reference

今天我将我的windows通用应用程序项目从github克隆到运行新安装的Visual Studio 2015的新机器上。

加载项目后,我注意到我的所有页面和属性都带有下划线红色,但有很多错误

CS0246 C# The type or namespace name "<name>" could not be found (are you missing a using directive or an assembly reference?)

以及其他如

CS0518 C# Predefined type 'System.Void' is not defined or imported

CS0012 C# The type '' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

CS1545 C# Property, indexer, or event 'Application.Suspending' is not supported by the language; try directly calling accessor methods 'Application.add_Suspending(SuspendingEventHandler)' or 'Application.remove_Suspending(EventRegistrationToken)'

我注意到CS0012实际上提供了解决问题所需的信息:

您必须添加对程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的引用。

但是,查看我的project.json文件,我可以看到

"dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
}

因此,项目将无法构建或运行,只列出了大量错误,您如何解决这个问题?

Solution Explorer中查看项目的References可以看出,即使Microsoft.NETCore.UniversalWindowsPlatform被列为依赖项,它也会从项目中丢失,这导致了问题。

Visual Studio知道程序集是一个依赖项,需要引用但是它似乎没有预装Visual Studio 2015,即使在安装过程中安装了所有Windows 10开发工具,它似乎也没有自动提取即使它知道它需要它的包!

要修复,您需要使用NuGet手动安装软件包,然后它将作为参考正确解析。

要执行此操作,请右键单击“ References ,然后单击“ Manage NuGet Packages...

NuGet Package Manager屏幕上,搜索Microsoft.NETCore.UniversalWindowsPlatform ,它将完全匹配。

单击右侧详细信息窗格中的“ Install ,Visual Studio将获取程序包并将其作为项目中的引用包含在内

红色下划线将全部消失,您可以继续处理您的项目!

我有类似的问题。 通用项目我创造了自己的参考。 Windows iot站点的一些示例在下载时没有引用。 NUGET说它已经安装好了。 对我来说,解决方案是构建解决方案并自行修复。

对我有用的是工具 - > nuget包管理器 - >管理解决方案的nuget包并更新解决方案的包,它添加了很多东西然后更新你的解决方案希望它适合你

你安装了SDK吗? 它可能无法找到与引用相关的文件。

windows 10 sdk

Windows 8.1 sdk

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM