Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Owl Saver on November 19, 2009, 12:44:41 am

Title: Starting to use API from C# and getting exception
Post by: Owl Saver 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("================================================================================");
      }
}
Title: Re: Starting to use API from C# and getting except
Post by: Hermes on November 19, 2009, 01:32:22 am
Mmm... Are you using the C# start template provided by Sparx guys?

/D
Title: Re: Starting to use API from C# and getting except
Post by: Geert Bellekens 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
Title: Re: Starting to use API from C# and getting except
Post by: smendonc 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.