Is ANID unique?

When developing the FeedPoint app I needed to encrypt the user credentials in order to store them in the isolated storage. So, I used AesManaged class to encrypt and decrypt the data. As a password key, I’ve decied to use the anonymous ID that we can retrieve utilizing the UserExtendedProperties class and I used the following code:

 string anid = UserExtendedProperties.GetValue(“ANID”) as string

After my application has been depoyed to the Marketplace, I started receiving reports from users saying that my application would just stop loading, unless it’s re-installed. And so I set to try to reproduce the issue. After a few days of starting and closing, activating and deactivating the application I was finally able to reproduce the issue. It seems like my decryption code was failing to decrypt the values. After more digging into the issue I’ve discovered that value of the “ANID” had suddenly changed! So I’ve taken look at the MSDN documentation page and saw that “The string returned when querying for the anonymous ID by specifying the “ANID” property name contains the 32 character anonymous identifier as well as other information used by the system.” and you need to exctract it like this:

string anid = UserExtendedProperties.GetValue(“ANID”) as string;
string anonymousUserId = anid.Substring(2, 32);

After I made a change in my app, the problem was gone. So, when using the ANID, please beware of this little nook. And of course RTFM 🙂

PS: The FeedPoint (version 1.2) the contains this fix has been deployed to the Marketplace. Due to the current bug in the marketplace, if you are using a trial version you will need to uninstall the app and then download and install the latest version

Comments (1)

  1. Jerry says:

    string anonymousUserId = anid.Substring(2, 32);

    this line will crash since the anid is maximum 32 in length………….although this is msdn's fault…