Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute'

I'm trying to run a .NET MVC application on my local computer that I got from GitHub.

When I hit run on Visual Studio, everything complies and a new browser window opens with the error:

CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute'

The compiler section in the same window, shows the following error:

enter image description here

I've checked on google and this seems to be the same error.

This guy was using a dynamic type himself, on the other hand I'm not using any dynamic type, this is being auto generated by .NET's compiler, and I'm using .net 4.5 which should has support for dynamics.

I tried to apply the same solution (Changing all System.Core references to 4.0) but the thing is that all of them are version 4.0 already.

Do you have any idea how could I resolve this?

like image 266
Alejandro Lozdziejski Avatar asked Aug 01 '15 11:08

Alejandro Lozdziejski


1 Answers

I had a similar error on a project I was trying to migrate. Try re-targeting the framework of the project back a version or two, and once you find a target version where you do not get the error, re-target back to the version you originally had trouble with.

I was getting the same error on a website project targeted for 4.6.2 that was referencing some older libraries, re-targeted it back to 4.5.1 and that resolved the error. I immediately re-targeted back to 4.6.2 and did not encounter the error again.

like image 132
Granicus Avatar answered Oct 08 '22 07:10

Granicus