Have you ever had an error crop up when debugging an application which has made you simply want to pull each hair out of your head one by one with a pair of tweezers because that would be less painful than debugging the error? Today I had just this happen to me.
Today when I hit F5 to launch our Silverlight application I received the following exception :
The body of this error message is
Error: Unhandled Error in Silverlight Application
Message: Failed to download the splash screen
Of course since I have the debugger I was going to attach to it, but sadly that was NO HELP. When reading error you notice it says that it failed to download the splash screen. This is really odd because when looking in the source it is there… In an effort to ‘remove the problem’ I removed the line of code from our ASPX page which setup the splash screen as a resource, the line below.
<param name='splashscreensource' value='SplashScreen.xaml' />
Thinking that this would solve my issue, at least for now, I hit F5 again. Things were different this time, but sadly not for the better. Now in place of getting the error message I simply got the default ‘blue dots’ from silverlight indicating that the xap was trying to load. This was really odd. I did what any developer would do, I hit F5 3-4 more times thinking that the problem would just magically go away, hey it does happen, but as you can guess it did not go away.
Because I had been making a bit of changes in the code and it was possible that I could have accidently really FUBARED my code base I shelved my code, blew away my ENTIRE branch and did a fresh pull. Yea, that did not either.
So my on branch was dead, but my co-worker who is in the same branch was able to launch and run the app just fine. In another effort to see if it was my branch code or my machine I decided to pull down the trunk (the parent of this particular branch) to see if I had the issue there… Yea no, that code worked just fine.
Because I knew it was not my machine it had to be code. I decided to start diffing the files I thought were causing the issues such as our default.aspx page, our login page along with a few other files. As you may have guessed NONE of these files were different.
Because I had been beating my head against this for greater than an hour I decided that I should move on to something else and come back to this later (I guess I was still holding out for the code fairy to magically fix my stuff while I was away).
Well later came and I had to go back to my branch to fix a production issue and this issue was still there. This time however things were a bit different, no the code fairy did not do her magic, my co-worker said ‘hey I got that a few minutes ago’. I was both elated and pissed at the same time. I was elated because maybe NOW I could solve my issue. I was pissed because this was the same co-worker I had talked to about this issue a few hours back and NOW they knew how to solve the issue.
So what was the issue? My co-worker was playing around with some security settings in our web.config file and had accidently committed is changes. It was these changes that was causing my issue. What did he change? He did 2 things
1) He setup a deny ALL authorization rule
2) He setup other rules to only allow a few pages to be open as such
The 2nd change was not a huge issue, it was the 1st one that was killing me. Because he had turned off anon access to the site my xap could not load and because my xap could not load the splash screen could not be presented to the user and for what ever reason Silverlight decided that in place of providing a meaningful message it would simply say it could not find my splash screen resource.
Since I knew the issue I was able to change my rule from deny to allow (in #1) and re-run the application…. finally I could fix bugs I created
The moral of the story here is that if you get an error saying you cannot access a resource in your xap file double check that IIS has access to the xap because if it does not you may get this issue.
The other moral of the story is that it should be 100% legal to cane a co-worker who commits a change that breaks you and does not even realize it. Ok caning may be harsh, at least they should buy you a beer.
Till next time,
01-25-2012 2:58 AM