Reference Component Microsoft.CSharp could not be found

孤人 提交于 2019-12-23 11:55:12

问题


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:

A get or set accessor expected

and warning:

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

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

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?


回答1:


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.

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

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:



来源:https://stackoverflow.com/questions/13252087/reference-component-microsoft-csharp-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!