There is no Yellow Icon (Exception) in my Internet Explorer when running Kompas ePaper, but my Visual Studio Output Window throws out these exceptions:
I tried hunting down the FileNotFoundException for 2 weeks without success. I thought I can get the exception message by catching exceptions and using Debug.WriteLine (well it works for some – see the message “Loaded Fonts1,2,3,15”)
Alas, it seems Visual Studio is not good enough for Silverlight Debugging, so I loaded up the mother-of-all debugging tools: WinDbg.
Here are the steps I did to find out what the FileNotFoundException refer to:
1. Download Windows Debugging Tools
IMPORTANT: Even if you’re running Windows Vista x64 and Windows 7 x64, you will need to download the 32-bit version!
This is because you will most likely run the Internet Explorer 32-bit version, not IE 64-bit. So to debug 32-bit apps you need to use 32-bit debuggers, eventhough you’re running 64-bit operating system. In future post, I will share my painful story of debugging Biztalk x64, SQL x64, SAP x64 and Visual Studio (hint: Visual Studio is a 32-bit app)
2. Find the Process ID that’s loading Silverlight (agcore.dll). Do not use Task Manager because since IE supports Tabbed-Browsing, there will be multiple IE processes. I used SysInternals’ Process Explorer:
3. Run WinDbg and press F6 (attach debugger to process) by choosing the correct PID of iexplorer.exe
4. Set the Debug Symbols Path for debugger by typing this command:
.sympath SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
5. Reload symbols by typing this command:
.reload
6. Load SOS extension for Silverlight, so you can debug managed programs:
.load C:\Program Files (x86)\Microsoft Silverlight\3.0.40818.0\sos
(Silverlight’s SOS.DLL is installed when you install the Silverlight Tools)
7. Check for Exceptions thrown into the heap (use !dumpheap command):
8. Note the Managed Pointer Address, and use !dumpheap again to find the real memory address:
9. Use the !pe command to Print Exception on the Memory Addresses:
Cools, now I know why the FileNotFoundException was thrown (Image_220.JPG) and where was it thrown (in the Constructor of IsolatedStorageFileStream)
So there… Visual Studio is not enough for Silverlight Developers… you need to learn WinDbg and SOS too.
On a bright side, learning WinDbg will make you a special programmer different from the rest :)
Oh and I heard rumors that in Redmond, Microsoft engineers use WinDbg to debug and not visual studio (except the VS team maybe).
Power to the SOS!