Are you getting the pointer from the part and trying to read it in assembly by any chance? What is the entity type? Is this entity in assembly, part or drawing? How do you store the id in the file? Are you using serialization? Make sure there is no extra symbols like trialing zeros when serializing/deserializing.