C# 找不到参考组件 Microsoft.CSharp
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13252087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reference Component Microsoft.CSharp could not be found
提问by Pseudorandom
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:
我在我在 Visual Studio 2010 开始的 C# 项目中发现了这个问题,当我转到另一台使用 2008 的 PC 时,我打开了 project.csprog:
A get or set accessor expected
预期的 get 或 set 访问器
and warning:
和警告:
The referenced component 'Microsoft.CSharp' could not be found.
找不到引用的组件“Microsoft.CSharp”。
I think is about .NET Framework or Microsoft.CSharp is not located, because it says that:
我认为是关于 .NET Framework 或 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`
无法解析此引用。找不到程序集“Microsoft.CSharp”。检查以确保程序集存在于磁盘上。如果您的代码需要此引用,您可能会收到编译错误`
but I don't know the problem, can you guys give me a solution?
但我不知道问题所在,你们能给我一个解决方案吗?
回答by Marc Gravell
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.
听起来您的目标是项目中的 .NET 4.0,然后尝试在仅针对 .NET 3.5 的 VS2008 中加载它。
If you needto use the project in VS2008, then you should re-target the project at .NET 3.5:
如果您需要在 VS2008 中使用该项目,那么您应该将项目重新定位到 .NET 3.5:


and then remove any incorrect references (they'll probably have yellow warning triangles on them anyway).
然后删除任何不正确的引用(无论如何它们可能会有黄色警告三角形)。
The A get or set accessor expectedalso 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:
该A get or set accessor expected还建议你使用新的C#语法,例如dynamic。如果您需要针对较旧的 C# 编译器,则不必这样做。如果您使用多个 IDE 版本并且这是一个问题,那么为了确保您不会意外这样做,您可以通过项目属性 -> 构建 -> 高级设置项目的语言版本:



