Derik Whittaker



Index was outside the bounds of the array when Obfuscating a LARGE WP7 application

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.
Build Error.

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,

Posted 02-22-2011 12:14 PM by Derik Whittaker
Filed under: , , , ,


About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)