3

Is there a way to get the code from a Silverlight publish?

My laptop has completely crashed, and the only thing I have left from my application, is the published website.

Is there a tool or something to get the code from my application?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jordy
  • 978
  • 2
  • 10
  • 20

4 Answers4

10

You can rename the xap to zip, extract it, and use Reflector to pull out the code. It won't recover it exactly or recover the XAML though. As far as I know there's no way to reverse engineer XAML.

Edit: +1 for Shawn for pointing out that the XAML is stored as plaintext resources, so you can recover that too. Not quite sure why it does that, but hey, it's good news :-)

Steven Robbins
  • 26,441
  • 7
  • 76
  • 90
4

Using .NET Reflector you can can all the XAML. It's stored as resources in plain text.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shawn Wildermuth
  • 7,318
  • 3
  • 23
  • 28
2

Try Silverlight Spy. It's a great tool for debugging Silverlight. If you use it in combination with .NET Reflector you can view the decompiled code of any running Silverlight application.

BTW, here are all features of Silverlight Spy.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sorskoot
  • 10,190
  • 6
  • 55
  • 98
  • how can i import my dll's or xap file in silverlight spy? – Jordy Oct 03 '09 at 20:40
  • you can browse to the url where your app is running with silverlight spy, and it will find the xap file. – Sorskoot Oct 04 '09 at 08:03
  • That's allready fixed, but where is the option to decompile my xap-file? – Jordy Oct 04 '09 at 08:49
  • In the explorer panel you can look at the contents of a xap file. after you've selected a dll. goto the view tab on the view panel. You have to have reflector installed. – Sorskoot Oct 04 '09 at 10:08
1

JetBrains have made DotPeek available. It is currently free (I hope it stays that way, unlike .NET Reflector).

It will also convert Silverlight DLL files all the way back to readable source code! I have tried it on several Silverlight projects, and it works like a charm.

**Note: as of the time of this writing it still gets a couple of things wrong: string concatenations and event handlers generate the wrong code.*

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202