Sparx Systems Forum

Discussion => Bugs and Issues => Topic started by: wmather on January 04, 2018, 12:11:26 am

Title: Orphaned EA.exe process - Interop.EA.dll [Solved]
Post by: wmather on January 04, 2018, 12:11:26 am
Hi,

I am trying to automate the generation of my own documents by using a hybrid repository to walk all the required tables and assemble the required records.

This all works well, but as soon as I use EA.Repository() to save images, after my application finished, I have rouge EA.exe processes still running.

Is there something I am doing wrong so that the COM API closes the EA instance it has opened?

This is my code. Normally I let GC run in it's own time, but just forcing in-case it was the GC holding some COM lock. Please note this is EA 13.5.1352 Professional Edition

Code: [Select]
        private void ExportDiagrams()
        {
            var eaRepos = new EA.Repository
            {
                SuppressEADialogs = true,
                SuppressSecurityDialog = true
            };
            eaRepos.OpenFile(options.EAPFile);

            foreach (var d in Diagrams)
            {
                d.SaveImage(options.WorkingDir, eaRepos);
            }

            eaRepos.CloseFile();
            eaRepos = null;
            GC.Collect();
        }

        // inside my Diagram class...
        public void SaveImage(string dirName, EA.Repository repository)
        {
            var pi = repository.GetProjectInterface();
            repository.OpenDiagram(Diagram_ID);
            pi.SaveDiagramImageToFile($@"{dirName}\\{Diagram_ID}.jpg");
            pi = null;
            repository.CloseDiagram(Diagram_ID);
        }
Title: Re: Orphaned EA.exe process - Interop.EA.dll
Post by: Geert Bellekens on January 04, 2018, 12:47:30 am
I think you need to call Repository.Exit()

Geert
Title: Re: Orphaned EA.exe process - Interop.EA.dll [Solved]
Post by: wmather on January 04, 2018, 12:58:33 am
damn! did not see that function even though it was in my face  :P

And yes, that does solve the problem as well