简体   繁体   English

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

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

Today I cloned my windows universal app project from github onto a new machine running a new install of Visual Studio 2015. 今天我将我的windows通用应用程序项目从github克隆到运行新安装的Visual Studio 2015的新机器上。

After the project loaded, I noticed that all of my pages and properties were underlined red with many errors 加载项目后,我注意到我的所有页面和属性都带有下划线红色,但有很多错误

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

as well as others such as 以及其他如

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)'

I noted that CS0012 actually gives information about what is needed to address the issue: 我注意到CS0012实际上提供了解决问题所需的信息:

You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 您必须添加对程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的引用。

Looking in my project.json file, however, I could see 但是,查看我的project.json文件,我可以看到

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

As a result the project will not build or run, just lists lots of errors, how can you fix this? 因此,项目将无法构建或运行,只列出了大量错误,您如何解决这个问题?

Looking in the References of the project in the Solution Explorer it can be seen that even though Microsoft.NETCore.UniversalWindowsPlatform is listed as a dependency, it's missing from the project and this is causing the issue. Solution Explorer中查看项目的References可以看出,即使Microsoft.NETCore.UniversalWindowsPlatform被列为依赖项,它也会从项目中丢失,这导致了问题。

Visual studio knows that the assembly is a dependency and needs to be referenced but it doesn't seem to come preinstalled with Visual Studio 2015, even when you install all of the Windows 10 development tools during setup, and it doesn't seem to autofetch the package even when it knows it needs it! Visual Studio知道程序集是一个依赖项,需要引用但是它似乎没有预装Visual Studio 2015,即使在安装过程中安装了所有Windows 10开发工具,它似乎也没有自动提取即使它知道它需要它的包!

To fix, you need to manually install the package using NuGet and it will then be resolved correctly as a reference. 要修复,您需要使用NuGet手动安装软件包,然后它将作为参考正确解析。

To do this, right click on References , then click Manage NuGet Packages... . 要执行此操作,请右键单击“ References ,然后单击“ Manage NuGet Packages...

On the NuGet Package Manager screen, search for Microsoft.NETCore.UniversalWindowsPlatform and it will be an exact match. NuGet Package Manager屏幕上,搜索Microsoft.NETCore.UniversalWindowsPlatform ,它将完全匹配。

Click on Install in the details pane on the right hand side and Visual Studio will fetch the package and include it as a reference in your project 单击右侧详细信息窗格中的“ Install ,Visual Studio将获取程序包并将其作为项目中的引用包含在内

The red underlining will then all disappear and you can continue working on your project! 红色下划线将全部消失,您可以继续处理您的项目!

I had similar problem. 我有类似的问题。 universal project I create my self had reference there. 通用项目我创造了自己的参考。 Some of the samples for windows iot sites didn't have reference when downloaded. Windows iot站点的一些示例在下载时没有引用。 NUGET said it was already installed. NUGET说它已经安装好了。 for me the solution was to build the solution and it repaired itself. 对我来说,解决方案是构建解决方案并自行修复。

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

Have you installed the SDKs? 你安装了SDK吗? Its possible that it cant find the files assosiated with the references. 它可能无法找到与引用相关的文件。

windows 10 sdk windows 10 sdk

windows 8.1 sdk Windows 8.1 sdk

暂无
暂无

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

相关问题 将通用Windows C#类库引用添加到通用Windows C ++ DLL项目Visual Studio 2015 - Adding a Universal Windows C# Class Library reference to a Universal Windows C++ DLL project Visual Studio 2015 Visual Studio 2015-新的Blank Universal App C#的存储菜单已禁用/丢失 - Visual Studio 2015 - Store menu disabled/missing for new Blank Universal App C# 尝试在Visual Studio 2015,c#,通用Windows应用程序中删除SQLite数据库中的条目,没有错误,但没有删除 - Trying to delete entries from SQLite db in Visual Studio 2015, c#, Universal Windows App, no errors, but not deletes Visual Studio:缺少对“Windows”的程序集引用 - Visual Studio: Missing assembly reference to “Windows” Visual Studio 2015中的UWP(通用Windows平台)Web服务C# - UWP (Universal Windows Platform) Web Service in Visual Studio 2015 C# 使用 Visual Studio 2015 的通用 Windows 10 应用程序 - Universal Windows 10 App Using Visual Studio 2015 Visual Studio 2015空白应用程序(通用Windows):CS0731 - Visual Studio 2015 Blank App (Universal Windows): CS0731 Visual Studio 2015:全新的通用应用程序,甚至不会编译。 为什么我缺少系统参考? - Visual Studio 2015: Brand New Universal app, won't even compile. Why am I missing System reference? Visual Studio 2015中C#中的未签名的朋友程序集 - Unsigned Friend Assembly in C# in Visual Studio 2015 无法在Visual Studio 2015中构建通用应用 - Cannot Build Universal App in Visual Studio 2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM