Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Kezia 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"
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 :)
-
try
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
-
Hi Geert,
It still throws the same error.. :(
But if I re-open the project, the package for both code above is created.
Cheers.
-
Then I'm all out of suggestions except: ask Sparx Support.
Geert
-
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).