C#项目中的错误

时间:2012-05-13 12:27:19

标签: c# visual-studio-2010 windows-phone-7

这是我的两个功能:

 public void SetCompanies()
    //set the Companies table from Shret.net DataBase
    {
        try
        {
            WebClient webClient = new WebClient();
            Uri uri = new Uri("http://api.sherut.net/?method=Company");
            webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);

            try
            {
                webClient.OpenReadAsync(uri);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
    void webClient_OpenReadCompleted(object sender, OpenWriteCompletedEventArgs e)
    {
        try
        {
            DataContractJsonSerializer serializer = null;
            var companies = (Companies)serializer.ReadObject(e.Result);
            foreach (Company c in companies.data)
            {
                MessageBox.Show(c.Name + " " + c.CompanyID);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
}

这是我得到的错误:

  

“'webClient_OpenReadCompleted'没有重载符合委托   'System.Net.OpenReadCompletedEventHandler'“

我不明白为什么,因为我在这个函数之后编写了处理程序...... 提前谢谢!

1 个答案:

答案 0 :(得分:8)

OpenReadCompleted不接受OpenWriteCompletedEventArgs