Book a Demo

Author Topic: Failed creating new package  (Read 6198 times)

Kezia

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Failed creating new package
« on: August 25, 2009, 04:03:30 pm »
Hi all,

I'm wondering why simple code below always gives me error
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt"

Code: [Select]
EA.Package newpkg = (EA.Package)pkg.Packages.AddNew("nuPkg", "");
newpkg.Update();

This is the way when creating new element or attribute, but it doesn't work on package. Anyone knows why?
Thanks :)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Failed creating new package
« Reply #1 on: August 25, 2009, 04:42:59 pm »
try
Code: [Select]
EA.Package newpkg = (EA.Package)pkg.Packages.AddNew("nuPkg", "Package");
newpkg.Update();
Collection.AddNew() operation is a generic operation on the generic EA.Collection. It has to know which type of object you are creating.
Maybe that it doesn't throw an error in some cases because it can somehow figure out the type of object to create.

Geert

Kezia

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Failed creating new package
« Reply #2 on: August 25, 2009, 05:40:13 pm »
Hi Geert,

It still throws the same error.. :(
But if I re-open the project, the package for both code above is created.

Cheers.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Failed creating new package
« Reply #3 on: August 25, 2009, 05:48:03 pm »
Then I'm all out of suggestions except: ask Sparx Support.

Geert

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Failed creating new package
« Reply #4 on: August 25, 2009, 11:05:49 pm »
Check that you are using a very recent version and build of EA. I think there was a recent issue where child packages could not be created via the API. This was quickly rectified (i.e. in the next or next but one build) at the time. I think this was since EA 7.5 came out but I am not sure. The problem might have been present for a few builds before it was reported in the forum (i.e. since sometime in EA 7.1).
No, you can't have it!