*Moved to: http://fluentbytes.com/how-to-easily-find-the-culprit-of-a-ms-internal-wrappedexception/
Today I was working on a Windows Phone application and In visual Studio everything looked fine. I started the Emulator and run the application and the application ended immediately. This normally indicates you have an unhandled exception, so next I started the application in debug mode.
Follow my new blog on http://fluentbytes.com
To my frustration, everything looked to be OK, but in my output window I saw that I was getting an MS.Internal.WrappedException but the debugger was unable to show me where it occurs and hence what the root cause of the problem was.
So I was kind of stuck. Searching the internet for a while gave me the impression that this might be caused by some invalid XAML for the page I show, but on the other hand Visual Studio would not give me any clue that something might be wrong.
In my quest on finding what was going wrong I opened the page in Expression Blend, to see if that might give me a clue. and what do you think, it immediately showed me the message “Invalid XAML”!
One of the things I have on my page is an image where it’s URL source is constituted using a ValueConverter. in this value converter I test if the object is of the type int since that is what I agreed upon with guy building the webservice, but apparently he implemented it as a string in stead of an int. I used SOAP UI to get a request to the service and the resulting XML as an input document to generate designtime data. that way you can use the databing features with designtime data and can you see how your layout will really look when you run the application.
The great thing about blend is that it not only showed me that my XAML was incorrect, but it even showed me that the culprit of the problem was the value converter.
So my advice if you run into the similar experience of a MS.Internal.WrappedException thrown and everything looking OK in Visual Studio: Open it in Expression Blend and it will most likely show you right away what the problem with the XAML can be.
Cheers, Marcel