Visual Studio的2015年 - 的C#Windows通用应用程序缺少的程序集引用 [英] Visual Studio 2015 - C# Windows Universal App missing assembly reference

查看:1672
本文介绍了Visual Studio的2015年 - 的C#Windows通用应用程序缺少的程序集引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我克隆从GitHub我的窗户普遍的应用项目,在新机器上运行新安装Visual Studio 2015年。

Today I cloned my windows universal app project from github onto a new machine running a new install of Visual Studio 2015.

该项目加载后,我注意到,所有的我的网页和属性被强调红色许多错误

After the project loaded, I noticed that all of my pages and properties were underlined red with many errors

CS0246 C#中的类型或命名空间名称<名称>找不到(是否缺少using指令或程序集引用?)

,以及其他如

CS0518 C#预定义类型'System.Void没有定义或导入

CS0012 C#的类型''在未引用的程序集的定义。您必须添加到程序集的引用'mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089'。

CS1545 C#属性,索​​引器或事件Application.Suspending不被支持的语言;尝试直接调用访问方法Application.add_Suspending(SuspendingEventHandler)'或'Application.remove_Suspending(EventRegistrationToken)

我注意到,CS0012,其实是给予要解决这一问题,需要什么样的信息:

I noted that CS0012 actually gives information about what is needed to address the issue:

您必须添加一个引用到组装'mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089'。

You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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

Looking in my project.json file, however, I could see

"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?

推荐答案

展望在参考项目的解决方案资源管理器可以看出,即使 Microsoft.NETCore.UniversalWindowsPlatform 被列为依赖关系,它是从项目丢失,这是导致问题

Looking in the References of the project in the Solution Explorer it can be seen that even though Microsoft.NETCore.UniversalWindowsPlatformis listed as a dependency, it's missing from the project and this is causing the issue.

Visual Studio中知道该组件的依赖,需要引用,但它似乎并没有预装与Visual Studio 2015年,甚至当你安装所有的安装在Windows 10的开发工具,它似乎并不甚至自动提取的包时,它知道它需要它!

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!

要解决,你需要手动安装使用封装的NuGet,这将被作为参考解析正确。

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....

的NuGet包管理器屏幕,搜索 Microsoft.NETCore.UniversalWindowsPlatform ,这将是完全匹配的。

On the NuGet Package Manager screen, search for Microsoft.NETCore.UniversalWindowsPlatform and it will be an exact match.

点击安装在详细信息窗格右侧和Visual Studio将获取包并将其包含在你的项目

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

然后红色下划线将全部消失,你可以继续你的项目!

The red underlining will then all disappear and you can continue working on your project!

这篇关于Visual Studio的2015年 - 的C#Windows通用应用程序缺少的程序集引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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