o0r*_*s0o 8 c# mscorlib win-universal-app visual-studio-2015
今天我将我的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"
}
Run Code Online (Sandbox Code Playgroud)
因此,项目将无法构建或运行,只列出了大量错误,您如何解决这个问题?
o0r*_*s0o 23
查看References项目中的Solution Explorer内容可以看出即使Microsoft.NETCore.UniversalWindowsPlatform被列为依赖项,项目中也缺少它,这就是问题所在.
Visual Studio知道程序集是一个依赖项,需要引用但是它似乎没有预装Visual Studio 2015,即使在安装过程中安装了所有Windows 10开发工具,它似乎也没有自动提取即使它知道它需要它的包!
要修复,您需要使用NuGet手动安装软件包,然后它将作为参考正确解析.
为此,请右键单击References,然后单击Manage NuGet Packages....
在NuGet Package Manager屏幕上搜索Microsoft.NETCore.UniversalWindowsPlatform,它将完全匹配.
单击Install右侧的详细信息窗格,Visual Studio将获取该包并将其作为项目中的引用包含在内
红色下划线将全部消失,您可以继续处理您的项目!
| 归档时间: |
|
| 查看次数: |
16037 次 |
| 最近记录: |