Book a Demo

Author Topic: Launch EA Programmatically  (Read 4499 times)

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Launch EA Programmatically
« on: May 26, 2015, 05:51:57 pm »
Hello,

I would like to open an EA session via Windows service (C#) and do some actions behind the scenes.
I use the Repository API, however, don't know how to initialize it correctly.

  
Code: [Select]

    EA.Repository repository = null;
    repository.OpenFile(@"C:\test.eap");
    repository.Exit();

The OpenFile() fails due to wrong initialization :"Object reference not set to an instance of an object".

Any help would be appreciated!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Launch EA Programmatically
« Reply #1 on: May 26, 2015, 06:16:12 pm »
I think it would really be a good idea to follow a general programming course before trying something advances such as using the EA API.

You can a nullPointerException on OpenFile() because the object repository is null; which you defined the in the previous line.
You can't execute methods on null.


Geert

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Re: Launch EA Programmatically
« Reply #2 on: May 26, 2015, 06:53:14 pm »
Quote
I think it would really be a good idea to follow a general programming course before trying something advances such as using the EA API.

You can a nullPointerException on OpenFile() because the object repository is null; which you defined the in the previous line.
You can't execute methods on null.


Geert

That's exactly why I asked how to initialize the repository!

Windows service wouldn't allow to use  EA.Repository repository = new EA.Repository(); since it has no interaction with UI (ActiveX component).

If you have answer to the initialization question, It would be great.


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Launch EA Programmatically
« Reply #4 on: May 26, 2015, 07:39:21 pm »
Use
Code: [Select]
EA.Repository repository = new EA.RepositoryClass();
« Last Edit: May 26, 2015, 07:39:43 pm by Geert.Bellekens »