Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: adama on November 10, 2019, 03:44:32 am
-
==ERROR CONDITION===
Every time the my add-in code hits a line with a reference to Interop.EA.dll, I get this error:
"Retrieving the COM class factory for component with CLSID {72BF2E28-5DF4-4BD8-80D0-80C62BD9A026} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
==SPECS===
Running Sparx EA 15.0.1513. Build on Visual Studio 2019.
MyClass.dll is in the registry and exists as valid Add-in within EA.
Code has event handler for EA_OnPostNewElement.
Registry does NOT have that CLSID {72BF2E28-5DF4-4BD8-80D0-80C62BD9A026}.
Studio reports the GUID for Interop.EA.dll as {64FB2BF4-9EFA-11D2-8307-C45586000000}
In registry, found bunches of Interfaces with reference to {64FB2BF4-9EFA-11D2-8307-C45586000000}.
===CODE===
Here's the SIMPLIFIED code. Again, exception happens on first reference to EA library.
Function OnPostNewElement (Repository As EA.Repository, Info As EA.EventProperties) As Boolean
MsgBox("hello")
fred()
End Function
Private Sub fred()
MsgBox("hello3")
Dim e As New EA.Element
End Sub
=====WHAT I TRIED=============
1) I tried re-registering as follows:
C:\Windows\Microsoft.NET\Framework\v4.0.30319> regasm.exe "C:\Program Files (x86)\Sparx Systems\EA\Interop.EA.dll" /verbose
Microsoft .NET Framework Assembly Registration Utility version 4.7.3190.0 for Microsoft .NET Framework version 4.7.3190.0
Types registered successfully
2) Then,...
- I tear down, re-build, and re-register my dll.
- I get the same error no matter what I try. Can't find {72BF2E28-5DF4-4BD8-80D0-80C62BD9A026}
Any ideas out there? Thanks in advance.
-
This could have something to do with the OS. I'm running Windows 10 (64 bit), and it seems that the EA dll was complied as Win32. Thoughts?
-
Hi,
Not a direct help as such, but yes, EA is 32-bit and so are Add-Ins. But I think that's a red herring. I run EA and custom Add-Ins on Win10/x64 no problem.
Any issues with deployment are usually to do not with the application but with your development setup. If you take the trouble to set up the DLL and Setup projects correctly (assuming you use Visual Studio and WiX) you eliminate all manual steps like assembly registration. At the cost of having to run an installer every time you recompile your Add-In, true, but in my view that's worth it to avoid running into difficulties like this.
If you're doing a lot of hacking on your development machine, and by hacking I mean doing things like only installing your DLL partway, running assembly registration manually and sometimes forgetting, that sort of thing, you're likely to end up with a registry clogged up with references to old versions that no longer exist. This shouldn't cause any faults as such, the registry's fairly robust these days, but it doesn't help when you're trying to track down problems like this.
So the best I can offer is to uninstall your Add-In, make go through the registry and make sure there's nothing from old versions lurking there, clean and recompile the Add-In and reinstall it.
/Uffe
-
Thanks to Uffe for the wisdom and encouragement. Working in Visual Studio 2019, I believe i have made all approrpriate preparations. I have unregistered and re-registered my dll. Again, it runs, but fails when referencing Interop.EA.
===What else I tried====
A) rebooted the client machine. Exact problem referencing the missing GUID.
==Next..====
- Might will try to unregister and re-register Interop.EA.
-
I'd recommend to have a one night sleep between uninstall and re-install.
q.
-
Answer From 'Eve'
"You can't create an EA.Element. (Which is {72BF2E28-5DF4-4BD8-80D0-80C62BD9A026})
You get one from one of the API calls.
Eve
[email protected]
=====
-
Yes indeed. You can't do
Dim e As New EA.Element
You have to do something like
Dim e as EA.Element
set e = myPackage.Elements.AddNew("elementName", "Class") (http://Dim e as EA.Element
set e = myPackage.Elements.AddNew("elementName", "Class"))
Geert
-
Sorry, I completely missed that. Yes, no, you can't create model content that way, you have to use the Collection.AddNew() function. In the EA API you don't first create the thing and then place it into the model: you create it in the model, then make any changes to it and finally .Update() it to write the changes back to the repository.
It's worth checking out the Object Model (scripting) code samples. They apply to the Add-In Model too, but in the Object Model the Repository object is supplied as a global variable to your scripts while an Add-In receives the currently open Repository with every call from EA, and you then pass that object around through your code.
/Uffe