无法定义使用动态的类或成员,因为编译器需要类型

Ant*_*ton 10 c# asp.net

我在Asp.Net 3.5应用程序中使用Facebook SDK C#Library.当我尝试编译下面的代码时,给我错误.据我所知在4.0框架中使用动态类型.所以无论如何要重写它以使它工作?我有一个System.Core 3.5的引用,但它仍然没有编译

protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params.AllKeys.Contains("signed_request"))
            {
                var result = FacebookSignedRequest.Parse(FacebookContext.Current.AppSecret, Request.Params["signed_request"]);
                dynamic signedRequestValue = result.Data;
                this.RegistrationData = signedRequestValue.registration;
            }
            else
            {
                Response.Redirect("~/");
            }
        }

protected dynamic RegistrationData { get; set; }


Error   1   Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference to System.Core.dll?  

Error   2   Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference to System.Core.dll?  
Run Code Online (Sandbox Code Playgroud)

Cha*_*ndu 7

动态在C#4.0中可用.

您必须将应用程序转换为4.0版本将引用的程序集(System.Core)更改为4.0版本.


clo*_*bro 6

我的项目已经> 4.0.事实上,它是4.5.2.我遇到了这个错误.我做了什么来解决它:

  1. 我将项目更改为4.5.1.

  2. 我把它改回4.5.2.

  3. 问题解决了!

谢谢 - 希望这有助于那里的人.

PS - 不使用Facebook SDK,但这可能会有所帮助.