Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot define class or member that utilizes dynamic because the compiler required type

Tags:

c#

asp.net

I'm using Facebook SDK C# Library in Asp.Net 3.5 Application. When I'm trying to compile the code below give me the errors. As I know dynamic type using in 4.0 framework. So is anyway to rewrite it in order make it work? I have a reference to System.Core 3.5 but it's still not compiling

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?  
like image 393
Anton Avatar asked Mar 04 '11 05:03

Anton


2 Answers

dynamic is available in C# 4.0.

You have to convert your application to 4.0 version Change the referenced assemblies(System.Core) to 4.0 version.

like image 104
Chandu Avatar answered Oct 18 '22 01:10

Chandu


My project was already > 4.0. It was 4.5.2, in fact. I was experiencing this error. What I did to fix it:

  1. I changed the project to 4.5.1.

  2. I changed it back to 4.5.2.

  3. Problem solved!

Thanks - hope this helps someone out there.

PS - not using facebook SDK, but this could help.

like image 25
cr1pto Avatar answered Oct 18 '22 01:10

cr1pto