This is a follow up to my prior post on how to obfuscate a WP7 application, which is really just a call out to Bil’s post.
While trying to get a large (when I say large it takes 2+ hours just to obfuscate) WP7 application ready for publication I ran into an error while trying to obfuscate our entire .xap. The error was
Writing XAML: Phone.Controls.g.resources\themes/generic.xaml
Index was outside the bounds of the array.
No of course this error did NOT lead me to a solution so I tried a whole sort of changes to see if I could resolve it. What I did find is that I could obfuscate each assembly on its own, but not the entire .xap. Because I was getting desperate, and twitter was no help, I decided to email support at PreEmptive. In my email I provided them with my full build log.
Well, less than 24 hours later I received an email from their support with a few suggestions. I tried the suggestions below as suggested:
1. From the input tab: make sure that all third party assemblies within the XAP package have been marked as “Artifact”. (Right click on the third party dll and select “Exclude Assembly from Package”). This will instruct Dotfuscator to obfuscate/instrument only non-third party libraries.
2. From the settings tab: to start, enable “Control Flow” and “String Encryption”, and disable “Renaming” (i.e. set Disable Renaming to “Yes”).
3. If the XAP file is signed, you can provide a Certificate file by selecting the XAP file from the input tab, and selecting the properties
After doing this I was able to get my app obfuscated and loaded onto my emulator. I even went and ran it again but this time turning String Encryption back on and it still worked. Looks like the trick was to remove the 3rd party assemblies from the list of assemblies to scan, which makes sense.
Anyway, the moral of the story is that when obfuscating your WP7 application make sure you omit any 3rd party assemblies and you should be right as rain.
Till next time,
02-22-2011 12:14 PM