Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: vermeirl on November 18, 2011, 11:35:36 pm
-
I tried to build the smallest possible VB.net app (VS2010 on Windows 7):
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim my_rep As New EA.Repository
End Sub
End Class
It compiles fine, but I get a runtime error: COMException 0x80040154: can't find COM classfactory.
Question: does Interop.EA.dll need to be registered on my machine?
Remark: apart from the Interop.EA.dll, there is absolutely no EA-related code on my local disks; could this be an issue? Previously, on XP and VS2005, everything worked fine, but then I had a local install of EA.
Regards,
Luc Vermeiren
Belgium
-
Luc,
You can't create a new EA.Repository because the constructor is not public.
Using a workaround.
In VB I've used this:
'-------------------------------------------------------------
' Author: Geert Bellekens
' Date: 17/12/2007
' Description: Return the currently opened EA Model
'-------------------------------------------------------------
Public Function getCurrentRepository() As EA.repository
Dim EAapp As EA.App
Dim EArepository As EA.repository
Set EAapp = GetObject(, "EA.App")
'Warning when EA not open
If EAapp Is Nothing Then
MsgBox "Please Open Enterprise Architect"
'try again
Set getCurrentRepository = Me.getCurrentRepository
End If
'Warning when no repository is opened.
Set EArepository = EAapp.repository
If EArepository Is Nothing Then
MsgBox "Please open a Model in Enterprise Architect"
'try again
Set getCurrentRepository = Me.getCurrentRepository
End If
'return the found repository
Set getCurrentRepository = EAapp.repository
End Function
And yes, the interop.EA.dll needs to be registered for COM. Using regasm with option /codebase might just do the trick (otherwise you can install the free EA lite, which is probably a better idea)
Geert
-
Geert,
Thanks.
1. Not sure about the constructor being hidden. This line of code worked fine previously. Create a new repository object, and then call R.Openfile() and you're in business. No need for EA to be active.
2. Regsvr32 failed, but regasm worked. Unfortunately, problem remained.
3. Followed your suggestion and installed EALite. Bingo! It works (which proves my point nr. 1).
So I guess you need at least a local EA install for automation to work.
I would appreciate it if somebody from Sparx could confirm this.
Luc