简体   繁体   中英

Reference Component Microsoft.CSharp could not be found

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?

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:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM