Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
Generalavi codec information Pin
cbiacca16-May-03 14:25
cbiacca16-May-03 14:25 
GeneralRe: avi codec information Pin
The Limey16-May-03 18:13
The Limey16-May-03 18:13 
GeneralRe: avi codec information Pin
J. Dunlap16-May-03 18:29
J. Dunlap16-May-03 18:29 
GeneralRe: avi codec information Pin
The Limey16-May-03 20:20
The Limey16-May-03 20:20 
GeneralRe: avi codec information Pin
leppie16-May-03 22:39
leppie16-May-03 22:39 
GeneralRe: avi codec information Pin
cbiacca17-May-03 9:33
cbiacca17-May-03 9:33 
GeneralRe: avi codec information Pin
leppie17-May-03 12:08
leppie17-May-03 12:08 
GeneralConfused by Invoke Pin
Neil Lamka16-May-03 8:41
Neil Lamka16-May-03 8:41 
I am trying to play around with automating menu creation through external XML files. I've used several of the examples found in Code Project and I'm trying to bind the menu items to the MagicLibrary menu classes.

I'm getting close...but I'm stumped by trying to invoke a method in the calling application from my menu helper class. What I have is the following

The menu helper class is created by the main application and it reads the xml file and creates all the MagicLibrary MenuCommand items..that all seems to work fine. Within my menu helper class I have hooked into the menu click event and have the following method. The method retrieves a previously found and saved MethodInfo item that matches the actual method I want to call in the main application

private void menu_Click(object sender, System.EventArgs e)
{
object[] args = {sender, (object)e};
MethodInfo mi = (MethodInfo)onclickList[ (string)mc.Tag+".Click" ];
if (null != mi)
mi.Invoke(null, args);
}


The method I'm trying to invoke in the main application looks like the following

public void menuNew_Click(object sender, System.EventArgs e)
{
//* Code to do stuff in my application based on the menu click
//* event
}

What I get is an unhandled exception

An unhandled exception of type 'System.Reflection.TargetException' occurred in mscorlib.dll

Additional information: Non-static method requires a target.

Which has me stumped. I'm obviously not doing something right but I don't know what I'm missing.

Any help would be appreciated.

Thanks

Neil Lamka
neil@meetingworks.com
GeneralRe: Confused by Invoke Pin
leppie16-May-03 11:59
leppie16-May-03 11:59 
GeneralRe: Confused by Invoke Pin
Wesner Moise19-May-03 18:54
Wesner Moise19-May-03 18:54 
Generalquestion about unbound column in DataGrid Pin
cruscal16-May-03 6:06
cruscal16-May-03 6:06 
GeneralUrlDownloadToFile strange behaviour Pin
GriffonRL16-May-03 5:35
GriffonRL16-May-03 5:35 
GeneralRe: UrlDownloadToFile strange behaviour Pin
James T. Johnson16-May-03 13:44
James T. Johnson16-May-03 13:44 
GeneralRe: UrlDownloadToFile strange behaviour Pin
J. Dunlap16-May-03 13:48
J. Dunlap16-May-03 13:48 
GeneralRe: UrlDownloadToFile strange behaviour Pin
GriffonRL18-May-03 22:39
GriffonRL18-May-03 22:39 
GeneralRe: UrlDownloadToFile strange behaviour Pin
GriffonRL18-May-03 22:40
GriffonRL18-May-03 22:40 
GeneralIDocHostUIHandler and InternetExplorer object. Pin
GriffonRL16-May-03 4:14
GriffonRL16-May-03 4:14 
GeneralBest way to implement a game timer Pin
Anonymous16-May-03 4:10
Anonymous16-May-03 4:10 
General.NET Remoting related question Pin
stevb16-May-03 4:01
stevb16-May-03 4:01 
GeneralRe: .NET Remoting related question Pin
Andres Manggini16-May-03 12:31
Andres Manggini16-May-03 12:31 
GeneralDynamic business application questions Pin
tarmin16-May-03 0:05
tarmin16-May-03 0:05 
GeneralRe: Dynamic business application questions Pin
Daniel Turini16-May-03 0:58
Daniel Turini16-May-03 0:58 
GeneralRe: Dynamic business application questions Pin
shaunAustin16-May-03 1:09
shaunAustin16-May-03 1:09 
GeneralRe: Dynamic business application questions Pin
tarmin17-May-03 4:28
tarmin17-May-03 4:28 
GeneralXML documentation problem Pin
simwiz15-May-03 23:00
simwiz15-May-03 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.