Premise Is it safe to have a class with a property named "ID"?

Motorola Premise

georgejm

Active Member
Apparently not.  I've been working on a new project (Sonos integration with Premise) and had created a class with a property named "ID".  Premise took it with no issues, but I had a catastrophic failure on both my dev and prod instances of Premise the day after Christmas.   After a restart, Pemise wouldn't load complaining of a corrupt Premise XDO Schema file. 
 
After painstakingly repairing my setup, it happened again on Saturday (yes I take regular backups of my config, but they were corrupted as well).  I went through the "BAD" schema files Premise put in it's \Backup directory using Visual Studio, and noticed several "Duplicate attribute" errors.  When you look at the XML file that stores the Premise Schema, you'll notice that every object has an attribute called "ID" which contains the object ID for the Premise Object.  My class had a property called "ID" which showed up as a XML attribute in the schema called "ID".  So, every instance of my class in my setup had an illegal XML node in the schema which I believe was causing Premise to blow-up.  I renamed the property, and the problem hasn't returned. 
 
Hopefully, this helps someone avoid what happened to me. 
 
Of little help to you now but it is the first tip posted in the School of Hard Knock thread (circa 2008).
 
http://cocoontech.com/forums/topic/9745-school-of-hard-knocks/
 
 
Never name a property "ID"!
Premise stores all objects in XML format. Each object has a unique (hidden) identifier called "ID". If you name a property "ID" it will duplicate the existing object identifier ... and that violates an XML structural rule.

Nothing bad happens immediately. However, when Premise SYS Server starts up it loads the most recent backup of the XML data and halts on the line containing the duplicate identifiers. It discards the whole backup file and attempts to load an older backup copy. It will keep doing this until it finds a valid XML backup. If it runs out of available backups it reverts to a blank slate.

I discovered this while developing a new Module. Every backup copy had the duplicated "ID" so SYS Server was unable to load any of them! To find the offending line, change the backup file's extension from XDO to XML and open it with Internet Explorer. IE will display the XML file, halt at the offending line, and print an error message.

In conclusion, you should avoid creating any two properties with the same name!
 
Yup.  I wish I had remembered that post!  I'm getting old and can't remember stuff like I used to   :wacko:
 
I got caught in the same trap a few months back when building a module for my preamp.  Took me a while before remembering about that post!
 
Back
Top