Book a Demo

Author Topic: Activator.CreateInstance doesn't create second instance  (Read 3245 times)

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Activator.CreateInstance doesn't create second instance
« on: December 08, 2018, 08:25:19 am »
Hello,

I've got ASP.NET Core 2.1 app that is accessing EA repository. The code below works fine until I want to create another instance. When I use the code again, the current instance of EA is used, so I lose the connection to the first repository. Is there any witted solution to this problem?

Code: [Select]
EA.App eaApp = (EA.App)Activator.CreateInstance(Type.GetTypeFromProgID("EA.App", true));
eaApp.Repository.OpenFile(_repository);
EA.Element test = eaApp.Repository.GetElementByGuid(_testGUID);

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Activator.CreateInstance doesn't create second instance
« Reply #1 on: December 08, 2018, 05:36:08 pm »
You should be able to do something like this:

Code: [Select]
      EA.Repository r = new EA.Repository();
      r.OpenFile("c:\\eatest.eap");

See also: https://www.sparxsystems.com/enterprise_architect_user_guide/14.0/automation/automation_connect_setup.html

Geert