Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello, I did a code for login which return json value and I convert it through DynamicJsonConverter but it showing error :"No overload for method 'Deserialize' takes 2 arguments" and my code is here :
//login code
      private void button1_Click(object sender, EventArgs e)
      {
          string query = ("aUserName=" + "abc" + "&aPassword=" + "xyz").ToString();
          WebClient wc = new WebClient();
          wc.DownloadStringAsync(new Uri("http://dev.livestuff.com/.LoginAsJSON?" + query));
          wc.DownloadStringCompleted += wc_DownloadStringCompleted;
      }
      /
      /****** Code to serialize the login data *****/
      void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
      {

          var serializer = new JavaScriptSerializer();
          serializer.RegisterConverters(new[] { new DynamicJsonConverter() });

         //showing error in this line
          dynamic obj = serializer.Deserialize(e.Result, typeof(object));

          dynamic dd = obj["HierarchyPosition"];

          if (dd == null)
          {
               MessageBox.Show("Email ID and/or Password is incorrect.");
          }
          else
          {

          }

      }

Anyone can suggests me to solve this problem.
Thanks.
Posted
Updated 14-Apr-14 21:16pm
v3

1 solution

JavaScriptSerializer.Deserialize Method can have 2 arguments.It should be like below.So check the datatypes of your method.

C#
JavaScriptSerializer.Deserialize Method (String, Type);

public Object Deserialize(
	string input,
	Type targetType
)

Parameters

input
Type: System.String
The JSON string to deserialize.

targetType
Type: System.Type
The type of the resulting object.


Please read this for more info:
JavaScriptSerializer.Deserialize Method (String, Type)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900