Author Topic: C# Plugin  (Read 6212 times)

lario

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
C# Plugin
« on: February 21, 2005, 10:51:03 am »
Could someone direct me to an example of creating a plugin in C#?

Thanks

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: C# Plugin
« Reply #1 on: February 21, 2005, 01:13:32 pm »
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

lario

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: C# Plugin
« Reply #2 on: February 22, 2005, 11:29:12 am »
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?

lario

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: C# Plugin
« Reply #3 on: February 22, 2005, 02:17:32 pm »
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.

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: C# Plugin
« Reply #4 on: February 23, 2005, 11:59:02 am »
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.
« Last Edit: February 23, 2005, 12:32:18 pm by fwoolz »
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


lario

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: C# Plugin
« Reply #5 on: March 02, 2005, 01:19:15 pm »
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

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: C# Plugin
« Reply #6 on: March 03, 2005, 01:11:52 pm »
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
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


Nick

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: C# Plugin
« Reply #7 on: March 09, 2005, 03:51:16 am »
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