Book a Demo

Author Topic: Add a new package exception  (Read 4150 times)

Dumller

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Add a new package exception
« on: April 15, 2011, 06:44:06 am »
I am trying to add a package hierarchy from an add-in. When I add a new package to an existing package collection and call Update() an exception is thrown: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." My add-in is written in C# using VS 2010.

EA.Package useCasePackage = FindPackageByName(pckgAnalysisRealization, aPackageName);
if (useCasePackage == null)
{
     useCasePackage = pckgAnalysisRealization.Packages.AddNew(aPackageName, "") as EA.Package;
     if (useCasePackage == null)
         return null;

     useCasePackage.Update(); // <- Fries here
     pckgAnalysisRealization.Packages.Refresh();
}

This is the pattern that I saw in the reference material. Am I missing something?

Dumller

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Add a new package exception
« Reply #1 on: April 15, 2011, 10:55:40 pm »
Just to add another clue, when I run outside of the debugger I get an EA dialog popup:

An error occurred while attempting to communicate with an Addin:
BHIEAAddins (BHIEAAddins.AddinMain)
"EA_MenuClick: Index out of bounds"
Please contact the add-in provider for assistance.

Colin Richardson

  • EA User
  • **
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: Add a new package exception
« Reply #2 on: May 04, 2011, 09:48:00 pm »
Yeah, I get that too when the name doesn't exist that I'm searching for - works fine if it exists.

Had to fall back manually looping through the packages collection  :(