Book a Demo

Author Topic: C# Creating sub-packages gives TargetInvEx  (Read 4660 times)

Dan Glasser

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
C# Creating sub-packages gives TargetInvEx
« on: January 08, 2011, 10:03:33 am »
I'm attempting to automate the creation of a diagram (particularly interested in DoDAF).  I am stuck on creating sub-packages.

I get the error "EA_MenuClick: Attempted to read or write protected memory.  This is often an indication that other memory is corrupt". when launching an AddIn that is simplified to the following code.  The error occurs when Updating the sub-package:

Code: [Select]
           Package rootNode = (Package) repository.Models.AddNew("MyRootNode", "");
            if (!rootNode.Update())
            {
                MessageBox.Show("Error updating package: " + rootNode.Name + " " + repository.GetLastError());
            }
            repository.Models.Refresh();

            Package example = (Package)rootNode.Packages.AddNew("Example Enterprise", "");
            if (![highlight]example.Update()[/highlight])
            {
                MessageBox.Show("Error updating package: " + example.Name + " " + repository.GetLastError());
            }

I am on version 7.1.832.  Any help is 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: C# Creating sub-packages gives TargetInvEx
« Reply #1 on: January 10, 2011, 09:34:11 pm »
Dan,

- Have you tried to indicate the type of element you are adding?
so AddNew("Example Enterprise","Package")?
- Try without the line repository.Models.Refresh(); (that doesn't do any good anyway)

Geert

Dan Glasser

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: C# Creating sub-packages gives TargetInvEx
« Reply #2 on: January 11, 2011, 01:54:20 am »
Geert,

Thank you for the suggestion.  Yes, I've tried changing the type.  The type "Package" yields the same result.  For what it's worth it the operation crashes EA but upon reloading the project the package/sub-package does exist.

- Dan

alesliehughes

  • EA Administrator
  • EA User
  • *****
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: C# Creating sub-packages gives TargetInvEx
« Reply #3 on: January 11, 2011, 08:58:45 am »
Hi Dan,

In the release notes for 833
....
Resolved issue calling Package.Update.


Alistair

Dan Glasser

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: C# Creating sub-packages gives TargetInvEx
« Reply #4 on: January 11, 2011, 09:26:44 am »
Alistair,

Thank you.  I tested the trial version of EA 8 and verified it worked and then located a copy of 7.1.834 and verified that it works there as well.  Thanks for your support.

- Dan