无法定义利用“动态"的类或成员,因为编译器需要类型"System.Runtime.CompilerServices.DynamicAttribute" [英] Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute'

查看:936
本文介绍了无法定义利用“动态"的类或成员,因为编译器需要类型"System.Runtime.CompilerServices.DynamicAttribute"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在从GitHub获得的本地计算机上运行.NET MVC应用程序.

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

当我在Visual Studio上运行Run时,一切都将遵循,并且会打开一个新的浏览器窗口,并显示错误:

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

CS1980:无法定义利用动态"的类或成员,因为编译器需要类型"System.Runtime.CompilerServices.DynamicAttribute"

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:

我已经在Google和

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

这个人自己使用的是动态类型,另一方面,我没有使用任何动态类型,它是由.NET的编译器自动生成的,而我使用的是.net 4.5,该版本应支持动态功能.

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.

我尝试应用相同的解决方案(将所有System.Core引用更改为4.0) 但事实是所有这些都已经是4.0版.

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?

推荐答案

在我尝试迁移的项目中,我遇到了类似的错误.尝试将项目框架重新定位到一个或两个版本,一旦找到没有错误的目标版本,就重新定位到最初遇到问题的版本.

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.

我在针对4.6.2的网站项目上遇到了相同的错误,该项目引用了一些较旧的库,将其重新定位为4.5.1,并解决了该错误.我立即将目标重新定位到4.6.2,再也没有遇到错误.

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.

这篇关于无法定义利用“动态"的类或成员,因为编译器需要类型"System.Runtime.CompilerServices.DynamicAttribute"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆