Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - EXploringEA

Pages: [1] 2 3 ... 11
General Board / Creating / coding a c# windows application in EA
« on: September 19, 2018, 04:48:13 am »

I have been exploring producing a C# Windows applications using EA, unfortunately the documentation seems a bit light in this area and hence I'd like to check with others who may have succeeded (or not)!

I have used the Model wizard to create a c# windows app.  It produces a package with form classes, with source code, project files, etc (all just copied a zip file), plus scripts.  So I can use the scripts to build and run the solution - OK. However, I am curious and want to check that I am not missing anything that can help beyond a trivial example.

So if, for example, I want to add more code to produce a real application, e.g. another dialog:-

1. Adding another form / class.
I create a diagram using Win32UI MDG for a dialog but it looks like I can only export a .rc file (c++) so no good (directly) for a c# project.  Therefore, I assume I need to create the 2 classes (assuming I want to view the form - which looks like I can only do in VS or similar) for my form and then type the code for the "form" and its "designer".  This means that it's only relationship to the EA screen design object will be a link (realisation) between these classes and the dialog.

2. Editing project/solution/resources
When adding classes there doesn't seem to be a mechanism to view/edit the project (and other) files to add a new class.  Hence I assume I need to edit these files (.csproj, .sln, .settings, assembly files) outside of EA.

The same issue exists when working on a class library (e.g. an EA Addin). I can produce and edit all the classes fine within EA however there doesn't appear to be a mechanism to create the project/settings/resource files?

So just to check.
  • Are my observations correct
  • Is the pattern just a "noddy" example, using predefined code without the potential for extension
  • EA doesn't provide support for coding a real c# windows application

Perhaps somebody who has done real code development of windows apps within EA may have some experience/comments on EA's capabilities that I have missed. Are there other development tools/addins besides VS / Sharpdevelop that are useful for code development with EA?

Many thanks

Not entirely clear what you are wanting to do.
If you want to launch a specific instance of the EA application programatically you can use  the microsoft ProcessStartInfo Class. For example, in the following will launch the .exe you specify.

Dim p As New Process
p.StartInfo.FileName = "C:\Program Files (x86)\Sparx Systems\EA\ea.exe" ' filename of specific EA .exe so could point to a different directory which has a different version
p.StartInfo.Arguments = "C:\Users\EXploringEA\Downloads\123.eap" 'e.g. filename of eap
Dim hasItStarted = p.Start()

This will launch the required version of EA and assuming its completely OK for different versions to coexist this should be fine.  I did a quick test and all seemed to work OK, but best ask sparx to confirm multiple versions are OK and there is no potential crossover.

Hope this helps.

Yes - uses the diagram.diagramobjects then for each of the diagramobjects use the ElementID to access the element object and its properties

I had this requirement sometime ago and used EA_OnNotifyContextItemModified but this doesn't let you know if this is due to a tagged value change. 

Hence, my approach was to use EA_OnContextItemChanged to track the selection of an element, and take a copy of tagged values before any changes.  Then when ContextItemModified is triggered a check can be made to see if there is any difference for a tagged value.  Not ideal.. 


Github for Installation Inspector is on the EXploringEA site and is
(Note: the code on GitHub is for V4 - not the current development release)

Regarding you problem can you post the contents of your cmd file that you have found doesn't work and I can take a look.


Further to Helmut's post - I have a newer version of the tool which can provide additional information e.g. Registry Tree view which may help.  For details and download link go to


Seems like a valid experiment rather than pure luck, and fortunate that you got a meaningful message!

All makes sense as loading the AddIn DLL is exactly what EA does.

Good to have a logical reason (and test).



Hi Helmut

Thanks for the information - I'd better make a note of this for future reference.  It is something I would never have thought about - what gave you the clue or was it just luck you found the solution?


Hi Helmut

Reading your post I have a vague recollection of a similar issue years ago where I ended up having to sign a DLL, but then miraculously the problem just disappeared after a few days so I didn't explore further.

Also, it wasn't clear from your post whether the problem happens on the same machine and for same users or not.

Thinking about what it could be:

If this isn't for a single user/machine my guess would be that it is related to some windows policy.  On taking a quick look Windows local security policy supports rule based actions for DLL's with AppLocker.  In this case it may be worth a look there to see if any rules configured for users / admin.  But a word of warning this is not an area where I have personally done a lot, I'm just aware of cases working with different systems where administrators have set machine/user policies that caused us issues.

Be interested to know the outcome.




Don't be put off by the "youngsters", I started using Excel VBA with EA in 2002, then later used VB.NET (At the time Java was my preference but couldn't get it to work with EA then; not sure where it is now).  Done a lot with EA and Excel including the XL part of eaDocX in VB.Net so know it is fit for purpose!

For some projects, where an off-the-shelf solution doesn't provide the functionality and dynamic interactions with Excel are not required I have used libraries both my own and the EPPlus open-source Excel library.  The later is a file based solution so useful for reading and creating /export Excel workbooks; it also avoids the need for the Excel Interop and the challenges that can present.


Hi Rich,


As pointed out it's not the language that's the issue with writing an AddIn - C+,C#,  - anything that can create a valid DLL.  In my experience writing AddIns is more about understanding the EA API and dealing with the quirks of windows.

BTW: These days I write nearly all my AddIns in VB.Net unless my customer specifically wants another language, although I'd probably draw the line at doing it in assembly language these days!

If it would help I'm sure I can provide some example projects including installers - what type of stuff are you trying to do?

Re the error, 800401F3 that is nothing to do with the language; the error message translates to Invalid class string, so this looks like your AddIn DLL isn't registered or name is not correct.  Suggest you download my free Installation Inspector as that may provide a bit of information.  V5 of the installer is in Beta but may be more useful as it includes registry search functions that may help find any mismatch between class name and the class names in your dll file.

I also have some information/examples on registration/installation on the public part of my tools site that may be of interest. As suggested by Uffe Wix works fine and worth getting a good working template sorted early on. 

And as you've probably guessed there are plenty of experts on the forum always ready to help.


Hi Helmut

Thanks for feature requests:

Item 1:  is now available in the test release (I've put a copy of the working development version DEVc).  You can either select the progID in the registry tree window (context menu) if the progID exists or select the query tab; press the Run query button (at bottom of the form), then type whatever ProgID / classname you wish to check, then press "Run query" - and wait; the query happens in the background (a query active label appears top RH), so you can carry on doing other stuff then return to the query window when query info text box goes green.  BTW: This is not limited to EA but will execute a query for any class.  You could enter a classID but an unlikely request; can be done from context menu options in the registry tree view.

I need to refine the UI and help file but in the meantime have updated V5 concept page with some more screenshots/descriptions.

Item 2:  Seems like this is a request to inspect an installer (msi) file and determine what rights will be required - have I understood your request correctly, if not perhaps you can expand - there may be bits that can be done if not all.  I am guessing that if it is I need to do some more research:-)  It may be as quick to just try!

@all addin developers.

Any more requests? ideas that could make it more useful.


Ever curious, I've had a play and can confirm that I find no way of dragging something from the EA UI onto a custom contol; no surprise as the control is a child with no clear link back to the EA UI code.  In fact, it's clear from the error message "There is no current diagram to perform this operation. Please select a diagram first" 

However, not sure what you application is, so this may be completely out of scope, but what you can do is track the context e.g. the last item selected in the project browser and click in the tab and capture the information relating to the relevant project browser object.  One could argue that it is easier in some ways that drag and drop i.e. -> click & click!  There are probably several variants of this approach depending on your specific requirements.


Hi Guillaume,

My guess is that EA is losing focus for some reason, but not entirely clear from your description. So a brute force way to try and bring EA to the the front after closing your forms is to call windows API to bring EA to foreground.

Something along the lines, in VB.Net but easy to convert to C# I'm sure:
1. declare functions and a constant
Code: [Select]
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
Declare Function ShowWindow Lib "user32.dll" (ByRef hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
Private Const SW_MAXIMIZE As Integer = 3

2. Get the process handle (of EA) and then set as ForeGround
Code: [Select]
Dim proc As Process = Process.GetCurrentProcess()
Dim hWnd As IntPtr = proc.MainWindowHandle
If (hWnd <> IntPtr.Zero) Then
    ShowWindow(hWnd, SW_MAXIMIZE)
End If

A quick test with this will at least identify/eliminate loss of focus as the issue.


Please forgive me if this is not considered the correct place for this post but I'm unsure how to let the AddIn developers who use my (free) EA Installation Inspector know that I'm working on a new "infrequent" release and keen to get any feature requests.

I have a page EA Inspector Development with some outline ideas and screenshots, with a link to download an evolving working development version.

So if you've found the EA Installation Inspector useful and would like some other functions do let me know.



Pages: [1] 2 3 ... 11