Author Topic: Starting to use API from C# and getting exception  (Read 3752 times)

Owl Saver

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
  • Never give up.
    • View Profile
Starting to use API from C# and getting exception
« on: November 19, 2009, 12:44:41 am »
Can someone help point me in the right direction to solve this problem? I have just started creating a C# program to access EA models. When I try to open the model and EA is running, I get an exception. If EA is not runing, it works. First I get a pop up that says "Failed to Create Empty Document". Then I get the following exception:

"The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"

The code I am using is:

bool RetVal = false;
m_Repository = new EA.RepositoryClass();

if (m_Repository == null)
{
      log.Fatal("EA API could not be started.");
      RetVal = false;
}
else
{
      if (m_Repository.OpenFile(base.FilePath))
      {
            RetVal = false;
            log.Fatal("Could not open " + base.FilePath + " in Read/Write mode.");
      }
      else
      {
            RetVal = true;
            log.Debug("Opened file = " + base.FilePath);
            log.Debug("================================================================================");
      }
}
« Last Edit: November 19, 2009, 12:45:06 am by MichaelWacey »

Hermes

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Starting to use API from C# and getting except
« Reply #1 on: November 19, 2009, 01:32:22 am »
Mmm... Are you using the C# start template provided by Sparx guys?

/D

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Starting to use API from C# and getting except
« Reply #2 on: November 19, 2009, 05:29:02 am »
Michael,

That error you are getting has nothing to do with the C# program you are creating. I sometimes get that error too when I try to start a second (or third) instance of EA from within Windows.

A reboot usually helps for a while, after which the problem re-occurs. I don't really know what causing it.

Geert

smendonc

  • EA User
  • **
  • Posts: 148
  • Karma: +5/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Starting to use API from C# and getting except
« Reply #3 on: November 19, 2009, 07:48:09 am »
If you haven't already, you might try opening up Task Manager and killing any EA processes that are hanging around in the background.  I've had this happen especially when testing; the instances don't always shut down cleanly and after a while no new ones are created.

Stan.