Invoke target throwing invalid cross-thread operate exception
Posted
by sqwerty
on Stack Overflow
See other posts from Stack Overflow
or by sqwerty
Published on 2010-06-15T13:59:54Z
Indexed on
2010/06/15
14:02 UTC
Read the original article
Hit count: 176
MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(notify, null);
This throws the following exception:
{"Exception has been thrown by the target of an invocation."}
With the following inner exception:
"Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."
If I comment out a line of code that sets the images for the context menu entries then it stops throwing the exception.
Any ideas?
© Stack Overflow or respective owner