.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GetObject method of transaction class gives exception

1 REPLY 1
Reply
Message 1 of 2
eranUZA53
394 Views, 1 Reply

GetObject method of transaction class gives exception

1. Draw line.
2. Save objectId of line to file.

3. Close document.
4. Open document
5. Load ObjectId from file
6. Try to get line object by this objectId
7. Get System.AccessViolationException: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

 

GetObject method of transaction class gives exception (that writed above) when I'm trying to access object after reopening drawing. That's all

  

Entity ent = Transaction.GetObject(id, OpenMode.ForWrite) as Entity;

System.AccessViolationException: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

any idea why?

1 REPLY 1
Message 2 of 2
Keith.Brown
in reply to: eranUZA53

ObjectId’s are reassigned everytime the drawing is loaded so you cannot save them off in this way.  Instead save the entity handle as it will persist across each session.  You can get the  objectId from the handle.

 

         

          long ln = Convert.ToInt64(handleAsString, 16);

          Handle hn = new Handle(ln);

          ObjectId id = db.GetObjectId(false,hn,0);

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report