Friday, August 14 2009
So today I came across a very interesting post about "Fluid Dynamic in Silverlight 3" using WriteableBitmap. WritableBitmap is a new feature in Silverlight 3 and from what I've seen greatly improves the rendering performance of complex pixel effects. It's a simple way to host a raster graphics surface (i.e. an area in which every pixel is re-drawn at every refresh) in a retained graphics system (like Silverlight). Ok so great, awesome tutorial. What's the problem?
The problem is that the blogger in question, Rick Barraza, decided not to share his code for whatever reason. Having a desire to understand how his effect works and as a supporter of open source software I was naturally frustrated. However, luckily I knew the inner workings of Silverlight 3 and I was able to get the code running on my own machine within a few minutes.
You see a *.xap file (i.e. a compiled Silverlight executable) is simply a *.zip file that has been renamed. The *.xap file contains the .NET assemblies that are used to run the Silverlight application along with a manifest file used at runtime. It was easy enough to find the location of the *.xap file for Rick's example by browsing the HTML source of his post which happens to be http://www.cynergysystems.com/blogs/blogs/rick.barraza/FluidDynamics/SilverlightFluidDynamics.xap. From there it was a few simple steps to get the code working on my computer:
- Download the *.xap file to your computer
- Renamed the *.xap file to a *.zip file
- Open that *.zip file to reveal the assembly: SilverlightFluidDynamics.dll
- Open SilverlightFluidDynamics.dll in .NET Reflector, which you can download for free here
-
Copy and paste all code that shows up in Reflector as shown below:
- Compile and run a new Visual Studio solution with the code you've just copied.
And BAM! you've got yourself a working solution from a compiled Silverlight 3 assembly. I hope there are no hard feelings Rick, it's just that in my opinion if you're going to share a solution you've developed either open source it or realize that all Silverlight executables you post on the web can be decompiled into source code with very little effort. Happy Hacking. Open Source ftw.
Comments
Jer said on Friday, August 14, 2009:
All your XAPs are belong to us.
Rob said on Sunday, August 16, 2009:
The xap renamed to zip will not open.
“The archive is either in unknown form or damaged” when opened with WinRar
“Cannot open file: it does not appear to be a valid archive” when opened with WinZip
Stick to silverlight, leave hacking to them that can do it.
Charlie Robbins said on Sunday, August 16, 2009:
@Rob works just fine when I opened it in WinRar 3.51
Here’s a screenshot
What version are you running?
BeaxiaMaype said on Monday, August 17, 2009:
Hello. And Bye.
Jonathan van de Veen said on Wednesday, August 19, 2009:
Hey Charlie, I use the rename/unzip part all the time when deploying my .xap files to test platforms and I need to change config files. I then drag these files back into the archive and rename it back to .xap and it works like a charm. Just don’t try to zip it yourself. That is likely to fail.