Book a Demo

Author Topic: C# argument list using EXEC_ADD_IN  (Read 2842 times)

Jim Beck

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
C# argument list using EXEC_ADD_IN
« on: February 03, 2010, 10:24:31 am »
Hello.  I'm not sure what the argument list should look like in a C# add-in function that is to be invoked from a code template.  (The help file shows an example for VB that uses Variant.)

I tried making a function with no additional arguments:

Code: [Select]
public void jim1(EA.Repository Repository)
{
   object item;
   EA.ObjectType t = Repository.GetTreeSelectedItem(out item);
}

and invoked it like this:

Code: [Select]
%EXEC_ADD_IN("CS_AddInFramework","jim1")%
That ended up with a dialog saying:

Code: [Select]
An error occurred while attempting to communicate with an Addin:
CS_AddinFramework (CS_AddinFramework.Main)
"jim1: Invalid Parameter(s)"
Please contact the add-in provider for assistance.

I also tried adding string arguments like in the C# example projects, but those are functions called by EA when menu items are clicked and they don't work from within a code template.  I can't find an example of C# called from a code template.

Can anyone tell me what is the right way?  I'll keep working on it and let you know.

Thanks! Jim

Jim Beck

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: C# argument list using EXEC_ADD_IN
« Reply #1 on: February 03, 2010, 10:40:37 am »
Oops.  That was fast.  Use "object":

Code: [Select]
public void jim1(EA.Repository Repository, object o)
{
}

At least EA didn't have a problem with this.  If you set a breakpoint in there then the oject o jsut has your arguments in it.  How simple.  I just wanted to stop anyone from taking the time to answer!

Jim