我有一个 'No overload for svc_methodNameCompleted matches delegate System.EventHandler...' 错误,我不知道如何解决?
I have a 'No overload for svc_methodNameCompleted matches delegate System.EventHandler...' Error and I dont know how to fix it?
您好,我的服务参考中的方法是。
public List<Lecture> ViewUsersLectures(string userID)
{
using (var context = new SE_App_DatabaseEntities())
{
// select query (linq style) to select all lectures from lectures table in database
var results = from r in context.Lectures
where r.UserID == userID
select r;
// return results to list which will we bind to a listbox in our mobile app
return results.ToList();
}
}
所以我使用了这个,但是我在事件处理程序行中有一个错误,请问有什么帮助吗?
Service1Client svc = new Service1Client();
svc.ViewUsersLecturesCompleted += new EventHandler<ViewUsersLecturesCompletedEventArgs>(svc_ViewUsersLecturesCompleted);
svc.ViewUsersLecturesAsync(userID);
我完成的方法如下
void svc_ViewUsersLecturesCompleted(object sender, ViewLecturesCompletedEventArgs e)
{
if (e.Error == null)
{
// bind profiles to listbox
LecturesListBox.ItemsSource = e.Result;
MessageBox.Show("Profiles downloaded!", "Success", MessageBoxButton.OK);
}
else
{
MessageBox.Show("Problem viewing lectures", "Unsuccessful", MessageBoxButton.OK);
Console.WriteLine("An error occured:" + e.Error);
}
}
可能是您的 Completed 方法的 EventArgs 类型不匹配(缺少 "Users")?
无效svc_ViewUsersLecturesCompleted(对象发送者,视图用户LecturesCompletedEventArgs e)
您好,我的服务参考中的方法是。
public List<Lecture> ViewUsersLectures(string userID)
{
using (var context = new SE_App_DatabaseEntities())
{
// select query (linq style) to select all lectures from lectures table in database
var results = from r in context.Lectures
where r.UserID == userID
select r;
// return results to list which will we bind to a listbox in our mobile app
return results.ToList();
}
}
所以我使用了这个,但是我在事件处理程序行中有一个错误,请问有什么帮助吗?
Service1Client svc = new Service1Client();
svc.ViewUsersLecturesCompleted += new EventHandler<ViewUsersLecturesCompletedEventArgs>(svc_ViewUsersLecturesCompleted);
svc.ViewUsersLecturesAsync(userID);
我完成的方法如下
void svc_ViewUsersLecturesCompleted(object sender, ViewLecturesCompletedEventArgs e)
{
if (e.Error == null)
{
// bind profiles to listbox
LecturesListBox.ItemsSource = e.Result;
MessageBox.Show("Profiles downloaded!", "Success", MessageBoxButton.OK);
}
else
{
MessageBox.Show("Problem viewing lectures", "Unsuccessful", MessageBoxButton.OK);
Console.WriteLine("An error occured:" + e.Error);
}
}
可能是您的 Completed 方法的 EventArgs 类型不匹配(缺少 "Users")?
无效svc_ViewUsersLecturesCompleted(对象发送者,视图用户LecturesCompletedEventArgs e)