Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Stuart Trotter on July 18, 2006, 07:12:26 am
-
Hi,
I need some urgent help with a C# add-in which I am trying to write. I have been through the example add-ins on the web site and I have managed to get my add-in to install into EA without error. However when I try to execute a method in the add-in using the EXEC_ADD_IN macro from a code template, I get an invalid parameter(s) error which is driving me round the bend >:(
code sample:
public object STGetClassAttributes(EA.Repository Repository)
{
return "";
}
as you can see I've made the method as simple as possible just to try and get something to run. If anyone has any ideas (anything at all), I'd really appreciate it.
Thanks,
Stuart
-
Stuart,
What's giving you the error, EA or C#?
In the latter case would explicitly downcasting the return work? Something along these lines:
return (object) "";
Apart from that I don't know, but please post the solution when you find it. I've been putting off building an internal add-in with C# but am now about to start. I will likely run into the same issue.
David
-
Hi David,
The error is being raised by EA when I run the code gen, but I'll try your suggestion and let you know how it goes.
Thanks,
Stuart
-
David,
'Fraid no joy, I get the same behaviour.
Cheers,
Stuart
-
I didn't think it would work if the error was from EA. We'll have to wait for the other members or Sparx to give us some hints.
Hang in there Stuart. Someone must have seen this before, and there are working add-ins out there.
-
Just a thought...
What about declaring STGetObjectAttributes as type string instead of type object? Even though you are returning a string, it may be cast to an object before EA gets to it. That would seem to contradict the return type indicated in section 10.4.1.4.2.4 of the EA User Guide (as of build 792).
-
The method signature must include the repository object, and an array for any additional arguments. Using the below example, convert the second parameter to string[], then use args[n] to access any additional parameters passed from the EXEC_ADD_IN call.
// sample EXEC_ADD_IN call
public object MyAddInFunction(EA.Repository repository, object argsObject)
{
string[] args = (string[])argsObject;
return "";
}
Hope this helps.
-
Hi,
Sorry I've taken so long to get back to you, I just wanted to say thanks a million, the argObjects worked like a charm!!!
Cheers,
Stuart