Book a Demo

Author Topic: Repository.GetPackageById broken?  (Read 5370 times)

potterm

  • EA User
  • **
  • Posts: 126
  • Karma: +0/-0
    • View Profile
Repository.GetPackageById broken?
« on: March 30, 2011, 11:30:22 pm »
I'm having a problem in an AddIn when calling GetPackageById, although for the time being I'm running the code from a test harness (not from EA via the Add-in route).

Anyway, I'm trying to obtain the containing package for an element in the model and get this error:

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

To check that this wasn't some sort of resource issue with the AddIn I even built a very small text executable in C# to reproduce it - see code below:

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            EA.Repository rep = new EA.Repository();
            rep.OpenFile(@"C:\Model.EAP");

            EA.Element elem = rep.GetElementByGuid("{16BEFFF9-2983-46d7-BC96-C695731525AD}");
            int packId = elem.PackageID;
            EA.Package pack = rep.GetPackageByID(packId);
        }
    }
}

The failure happens in the last line of executable code ("EA.Package pack = ...").  The GUID used for the element is just one of the elements in the model.  I've imported the EAP database files into an Access DB and checked that the PackageID reference returned from the element is correct, so I don't think it's a model problem (and besides I've tried it with different elements and with entirely different models and still get the same failure).

Does anyone have any ideas what's causing this (and whether there's a work around)?

Thanks,
Martin.

P.S. I'm running on Windows 7 Enterprise (no SP) and EA 8.0 build 864.  Addin is built in Visual C# 2010 Express.  Note that all other aspects of the add in (which queries the model extensively) work without problem.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Repository.GetPackageById broken?
« Reply #1 on: March 31, 2011, 12:06:43 am »
Unlikely it's broken. Works for me. Verify elem and packID are defined.

q.

potterm

  • EA User
  • **
  • Posts: 126
  • Karma: +0/-0
    • View Profile
Re: Repository.GetPackageById broken?
« Reply #2 on: March 31, 2011, 12:20:07 am »
Quote
Verify elem and packID are defined.

Thanks qwerty - I can see that both elem and PackId are fine - when it fails I can inspect these variables in the VS debugger.  When this happened in the original add-in I copied the packID and then searched for it in the model (having copied the content to an Access DB) and verified that the packID was present.

Sounds like it might be some local configuration issue then (the worst of all possible problems).  Strange, because all of the other API calls I'm using are working without problem.

potterm

  • EA User
  • **
  • Posts: 126
  • Karma: +0/-0
    • View Profile
Re: Repository.GetPackageById broken?
« Reply #3 on: March 31, 2011, 01:11:14 am »
I managed to resolve this in the end by re-installing build 864 and selecting the "Repair" option.  Clearly something was updated on my system which caused EA problems and the re-install seems to have fixed it (Windows DLL hell strikes again?).