找不到引用组件 Microsoft.CSharp

Reference Component Microsoft.CSharp could not be found(找不到引用组件 Microsoft.CSharp)

本文介绍了找不到引用组件 Microsoft.CSharp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我从 Visual Studio 2010 开始的 C# 项目中发现了这个问题,当我转到另一台使用 2008 的 PC 时,我打开了 project.csprog:

I found this problem on my C# project which I started at Visual Studio 2010, when I go to another PC I use 2008, I open the project.csprog:

需要一个 get 或 set 访问器

A get or set accessor expected

和警告:

找不到引用的组件Microsoft.CSharp".

The referenced component 'Microsoft.CSharp' could not be found.

我认为是关于 .NET Framework 或 Microsoft.CSharp 没有找到,因为它说:

I think is about .NET Framework or Microsoft.CSharp is not located, because it says that:

无法解析此引用.找不到程序集Microsoft.CSharp".检查以确保该程序集存在于磁盘上.如果您的代码需要此引用,则可能会出现编译错误`

Could not resolve this reference. Could not locate the assembly "Microsoft.CSharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors`

但我不知道问题所在,你们能给我一个解决方案吗?

but I don't know the problem, can you guys give me a solution?

推荐答案

听起来您在项目中以 .NET 4.0 为目标,然后尝试在仅针对 .NET 3.5 的 VS2008 中加载它.

It sounds like you are targeting .NET 4.0 in the project, and then trying to load it in VS2008 which only targets up to .NET 3.5.

如果您需要在 VS2008 中使用该项目,那么您应该将该项目重新定位到 .NET 3.5:

If you need to use the project in VS2008, then you should re-target the project at .NET 3.5:

然后删除所有不正确的引用(无论如何,它们可能会有黄色警告三角形).

and then remove any incorrect references (they'll probably have yellow warning triangles on them anyway).

A get or set accessor expected 还建议您使用新的 C# 语法,例如 dynamic.如果您需要针对较旧的 C# 编译器,则必须不要这样做.如果您使用多个 IDE 版本并且这是一个问题,那么为确保您不会意外这样做,您可以通过 Project Properties -> Build -> Advanced 设置项目的语言版本:

The A get or set accessor expected also suggests you're using new C# syntax, for example dynamic. If you need to target older C# compilers, you'll have to not do that. If you are using multiple IDE versions and it is being a problem, then to ensure you don't do that accidentally you can set the language version for the project via Project Properties -> Build -> Advanced:

这篇关于找不到引用组件 Microsoft.CSharp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:找不到引用组件 Microsoft.CSharp

基础教程推荐