Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: lario on February 21, 2005, 10:51:03 am
-
Could someone direct me to an example of creating a plugin in C#?
Thanks
-
Hi Lario,
We don't currently have an example C# addin for EA. When we do you should be able to find it at http://www.sparxsystems.com.au/AutIntExamples.htm.
For now you can find some example code and some instructions at http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=Automation;action=display;num=1103556650.
I hope that helps.
Simon
-
Thanks. I follwed the example and have created a DLL.
The dll is called CallLibrary2.dll, the namespace is EAHelper and the class is called EAHelper.
I tried to follow the User Guide 4.51 Section 12.3.2.1.2 to no avail
I ran regasm on the dll
What should the ProjectName be?
What should default value be?
Does the dll have to be in an specific directory?
-
I should add that everything I have tried causes a error to occur when I start EA. The error is :
There was an error loading add-in:
EAHelper(EAHelper.EAHelpher)
Remove it from the list of Add-ins?
***
In this case I used EAHelper as the project name and EAHelper.EAHelper as the calls name.
-
lario,
I had this happen while I was trying to get the EAHelper addin to work. This was due to having the .dll in the wrong directory location, so EA couldn't find the add-in when it tried to load it.
After I built the .dll, I copied it to the EA executable directory, then ran regasm so that it pointed to this location for the .dll. Once I did this, it all worked OK.
Hope this helps!
Cheers,
Fred Woolsey
BTW--I named the .dll "EAHelper.dll", project name EAHelper.
PPS: Here's the relevant registry info:
Registry (.reg) file for entry created by regasm:
===================================================
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F938}]
@="EAHelper.EAHelper"
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F938}\Implemented Categories]
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F938}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F938}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="EAHelper.EAHelper"
"Assembly"="EAHelper, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v1.1.4322"
"CodeBase"="file:///C:/Documents and Settings/Administrator/Desktop/Visual Studio Projects/EAHelper/EAHelper/bin/Debug/EAHelper.DLL"
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F938}\InprocServer32\1.0.1.0]
"Class"="EAHelper.EAHelper"
"Assembly"="EAHelper, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v1.1.4322"
"CodeBase"="file:///C:/Documents and Settings/Administrator/Desktop/Visual Studio Projects/EAHelper/EAHelper/bin/Debug/EAHelper.DLL"
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F938}\ProgId]
@="EAHelper.EAHelper"
==================================================
.reg file for Addin:
==================================================
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins]
[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins\EAHelper]
@="EAHelper.EAHelper"
[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins\Reports]
@="EADocuments.EaAddin"
==================================================
It's interesting to note that the CodeBase entry still points to the (now non-existent) original location in the Visual Studio project folder, yet the add-in works just fine. (Note that I added a little functionality since the code was posted originally.) Nevertheless, the add-in is in the same directory as the EA program file itself; this may be a requirement since the assembly was not built with a strong name.
-
I copied EAHelper.dll to C:\Program Files\Sparx Systems\EA.
I ran regasm on EAHelper.dll. Here is the EAHelper.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F93A}]
@="EAHelper.EAHelper"
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F93A}\Implemented Categories]
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F93A}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F93A}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="EAHelper.EAHelper"
"Assembly"="EAHelper, Version=1.0.1882.19404, Culture=neutral, PublicKeyToken=47c899ad901b36f3"
"RuntimeVersion"="v2.0.40607"
"CodeBase"="file:///C:/Program Files/Sparx Systems/EA/EAHelper.dll"
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F93A}\InprocServer32\1.0.1882.19404]
"Class"="EAHelper.EAHelper"
"Assembly"="EAHelper, Version=1.0.1882.19404, Culture=neutral, PublicKeyToken=47c899ad901b36f3"
"RuntimeVersion"="v2.0.40607"
"CodeBase"="file:///C:/Program Files/Sparx Systems/EA/EAHelper.dll"
[HKEY_CLASSES_ROOT\CLSID\{0D53A3E8-E51A-49C7-944E-E72A2064F93A}\ProgId]
@="EAHelper.EAHelper"
@@@@@@@@@@@@@@@@
[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins]
[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins\EAHelper]
@="EAHelper.EAHelper"
*******************
I am still getting the error :
There was an error loading add-in:
EAHelper(EAHelper.EAHelpher)
Remove it from the list of Add-ins?
***
The error descrpition is not very helpful. I can not tell if it can not find the dll or if there is an error within the dll. I followed the example at http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=Automation;action=display;num=1103556650
-
lario,
I noticed from the registry entries that you're running v 2.0 of the .NET framework...the example on my machine was built with v 1.1 and runs on 1.1. Perhaps EA is not configured to work with .NET 2.0 assemblies (yet)? You might try compiling and installing the example on a machine running both EA and v 1.1 of .NET.
Cheers,
Fred Woolsey
-
Lario,
I don't know if you have been able to resolve this yet, but I had the same problem a while ago with a C# addin
and the only way I could resolve it as follows;
Where the help file says to add the deafult registry string as [project name].[class name], I had to add [name space].[class name].
Therefore, I had an addin where the class was called MyAddin and it was in a name space called EA.Addins.
The registry entry I had to use was;
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddIns\EA_AddIns]
@="EA.AddIns.MyAddin"
Cheers
Nick