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

前端 未结 3 2170
礼貌的吻别
礼貌的吻别 2021-02-20 11:47

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 i

相关标签:
3条回答
  • 2021-02-20 12:03

    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.

    0 讨论(0)
  • 2021-02-20 12:03

    If you don't want to use dynamic, you don't have to.

    var client = new FacebookClient();
    var me = client.Get("totten") as IDictionary<string, object>;
    string firstName = (string)me["first_name"];
    string lastName = me["last_name"].ToString();
    

    This tutorial explains it more in depth

    0 讨论(0)
  • 2021-02-20 12:14

    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.

    0 讨论(0)
提交回复
热议问题