2

In Enterprise Architect, I can use the .NET C# API to open an EA file and then extract some info. This is working as expected. However, when I'm done extracting info using the EA COM Interop API, and my .NET app is terminated, I still have EA processes running. Thus, when I do

var repo = new EA.RepositoryClass();
repo.OpenFile(@"c:\Test.eapx");
// extract info

I expect to call

repo.Dispose();

or something along those lines. I do have a

repo.CloseFile();

but that does not kill the EA process.

How to cleanup my EA resources?

Ruudjah
  • 807
  • 7
  • 27
  • https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.releasecomobject?view=netframework-4.8 – mjwills Jun 08 '19 at 12:10
  • Unfortunately, does not cause the ea process to die. – Ruudjah Jun 08 '19 at 12:29
  • I do not know this API, but generally you can try to look for EA in running processes that have a handle to a specific eapx file. Maybe it will help: https://stackoverflow.com/questions/177146/how-do-i-get-the-list-of-open-file-handles-by-process-in-c – EKOlog Jun 08 '19 at 14:05

1 Answers1

1

Your EA process should stop on it's own once the EA objects run out of scope and are garbage collected.

If you can't or don't want to wait for that you can use EA.Repository.Exit()

Documentation:

Exit

Notes: Shuts down Enterprise Architect immediately. Used by .NET programmers where the garbage collector does not immediately release all referenced COM objects.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50