Author Topic: Code Generation From EXEC_ADD_IN macro??  (Read 2150 times)

chiweis

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Code Generation From EXEC_ADD_IN macro??
« on: April 09, 2007, 02:22:49 am »
Hello.

I'm trying to use the EXEC_ADD_IN macro in my code templates, but there are something wrong. :-/

I use the EXEC_ADD_IN macro as follows:

$res = %EXEC_ADD_IN("CS_AddinFramework", "MyAddInFunction", classGUID)%

Also, I have modified the C# example CS_AddinFramework to do demonstrations. The code is as follows:

--
using System;
using System.Windows.Forms;

namespace CS_AddinFramework
{
 public class Main
 {
   public String EA_Connect(EA.Repository Repository)
   {
     System.Windows.Forms.MessageBox.Show("Hello!!");
     return "a string";
   }

   public void EA_Disconnect()  
   {
     GC.Collect();  
     GC.WaitForPendingFinalizers();
     System.Windows.Forms.MessageBox.Show("Bye!!");
   }

   public object MyAddInFunction(EA.Repository repository, object argsObject)
   {
     string[] args = (string[])argsObject;  
     EA.Element e = repository.GetElementByGuid(args[0]);
     return e.Name;
   }
--

The necessary settings in .NET 2003 have been done, including Interop.EA.dll reference, project properties, and the registry:[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins\CS_AddinFramework ]
@="CS_AddinFramework.Main"

The result is that the messagebox of "Hello!!" and "Bye!!" appear when start/close the EA program, but the function "MyAddInFunction" doesn't have any reaction.  >:(

I just want to get the element name from the EXEC_ADD_IN macro, and save the name into the variable $res.

What did I miss??  ???
Thx.