Error binding to target method.

Topics: CAB & Smart Client Software Factory
Feb 12, 2007 at 8:33 AM
Hello everybody.

I'm getting crazy with an error which i'm getting on runtime.

I've added a new business module, and in its ModuleController class i've added a CommandHandler, and when this module loads i get this error:

Failed to load module from assembly ClientSearchModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Error was:
Error binding to target method.

If I remove the CommandHandler attrribut, everything goes well, and application runs without problem.

Why can this happends?
Feb 12, 2007 at 2:55 PM
Hello Rotten,

Could you show me how you are using the attribute?

CommandHandler("Command")
...

Are you using VB or C#? (just so I can respond properly)

Jordon
Feb 13, 2007 at 8:02 AM
Hi Jordon , I'm using SCSF over C#.

The attribute is using this form
CommandHandler(CommandNames.commandCloseClientSearch)
public void CloseClientSearch()
{
IListClientView listClientView = WorkItem.Items.Get<IListClientView>("listClientView");

if (listClientView != null)
{
WorkItem.Items.Remove(listClientView);
}

}

And in the ExtendToolStrip() method of ModuleController.cs class I have this

private void ExtendToolStrip()
{

ToolStripMenuItem btnVerClientes = new ToolStripMenuItem();
btnVerClientes.Name = "btnVerClientes";
btnVerClientes.Text = "Ver Lista Clientes";
btnVerClientes.Size = new System.Drawing.Size(55, 20);
btnVerClientes.Checked = true;
//btnVerClientes.Click += new EventHandler(CloseClientSearch);

WorkItem.UIExtensionSitesUIExtensionSiteNames.ViewMenuItems.Add(btnVerClientes);
WorkItem.CommandsCommandNames.commandCloseClientSearch.AddInvoker(btnVerClientes, "Click");
}

Have I add the Click event or not??

Thanks for your help
Feb 13, 2007 at 8:16 AM
My light turn on!!!

Sorry, it was a newbie error, i forgot to add the parameters to the command method. Correct one is this form

CommandHandler(CommandNames.commandCloseClientSearch)
public void CloseClientSearch(object sender, EventArgs e)
{
IListClientView listClientView = WorkItem.Items.Get<IListClientView>("listClientView");

if (listClientView != null)
{
WorkItem.Items.Remove(listClientView);
}

}


Thanks everybody!
Feb 13, 2007 at 4:51 PM
Rotten,

You aren't the only one <<<--- Guilty.

That is why i asked, it seems to be the 80% of the time.

Jordon
Mar 1, 2007 at 2:52 PM
Thanks for the clarification on this! I have been hitting my head against the wall for too long on this.

--Adam