TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Miguel
NA
1
0
Error binding to target method
Jul 18 2009 8:55 PM
private void Record_Click(object sender, EventArgs e) { string[] eventsName = getSelectedEvents(); string[] controlName = getSelectedControls(); for (int i = 0; i < controlName.Length; i++) { Control ctrl = controls[controlName[i]]; foreach (EventInfo eventCtrl in ctrlEvents) { foreach (string eventName in eventsName) { if (eventCtrl.Name == eventName) { Type tDelegate = eventCtrl.EventHandlerType; MethodInfo methodToRegister = typeof(FormRecorder).GetMethod("registerInEventsList", BindingFlags.NonPublic | BindingFlags.Instance); Delegate d = Delegate.CreateDelegate(tDelegate, ctrl, methodToRegister); MethodInfo addHandler = eventCtrl.GetAddMethod(); Object[] addHandlerArgs = { d }; addHandler.Invoke(this, addHandlerArgs); } } } } Form1 form1 = new Form1(); form1.Show(); } ctrl is the control where i'm trying to raise the event, but Delegate d = Delegate.CreateDelegate(tDelegate, ctrl, methodToRegister); gives the following error: "Error binding to target method" if i use "this"(form) instead of the control works fine. Can someone help me with this?
Reply
Answers (
0
)
how to write code to send sms?
execute a command from a textbox