Pseudorandom
Pseudorandom

Reputation: 726

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 in 2008, I open the project.csproj:

A get or set accessor expected

and warning:

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

I thought that it was 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'm not sure about the problem, can you guys give me a solution? Really appreciated.

Upvotes: 6

Views: 27470

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1064324

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:

enter image description here

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:

enter image description here

Upvotes: 9

Related Questions