The project I’m currently working on is a Silverlight app and I’m in the throes of converting it to use the Composite Application Guidance framework from Microsoft. It’s been a reasonably mind-bending experience but also fairly straightforward if that’s possible. However, something popped up today that warrants mentioning.
I’m using the Unity Application Block as a Dependency Injection framework, also from Microsoft. I made a couple of changes to my app and started getting “Unable to resolve dependency” exceptions for a constructor of an object. The catch was, I was definitely registering all my dependencies and they were being created correctly. Turns out, I had just added the EventAggregator portion of the framework and had subscribed one of my events to a private event handler while I wasn’t paying attention which obviously won’t work since the event handler has to be public.
The problem occurred when the MethodAccessException did not get bubbled up correctly to my Module. Instead, it’s getting swallowed somewhere down in the ModuleInitializer and the exception getting tossed out is an “Unable to resolve dependency” exception which might confuse the hell out of you if you were positive you had all your dependencies resolved. I haven’t dug deep enough yet to figure out where the original exception is getting swallowed but I figured all this out when I wrapped a try-catch around the initialization code of the object that the framework was complaining about. Change the event handler to public and woohoo, we’re back in business.
As an aside, I’ve been pretty happy with the Composite Application Guidance framework. It’s a BIG chunk of functionality but it seems to be all things you really need in WPF and Silverlight apps. I’m hoping to have a few more posts about happier times with it soon but for now, I recommend checking it out if you’re working with WPF or Silverlight.
If you’re working in Silverlight and your app suddenly starts giving you the white screen of death, chances are there’s something wrong with the markup. Of course, since the white screen of death results in zero exceptions, sometimes it’s hard to track down what the problem is. Enter the Error Console in Firefox. If you get a WSOD, pop open Tools->Error Console in Firefox, scroll to the bottom of the list and you might be pleasantly surprised to find your problem described there.
I love Wireshark. It’s a network protocol analyzer that has saved me countless hours over the last year or so in debugging serialization and HTTP issues on a variety of projects. Today’s success story comes courtesy of Silverlight, WCF and the hazards of leaving slashes off the end of a URL.
I’m working on a project developing a Silverlight app and I’m in the process of adding a logging service on the server side. After I added the framework and skeleton yesterday to implement logging, my Silverlight app started throwing up a “This web page is being redirected to a new location. Would you like to resend the form data you have typed to the new location?” informational message. This was late in the day yesterday and having zero brain cells left to figure it out, I left it for today, hoping it would magically go away.
Of course, it didn’t. But having rejuvenated the two brain cells I have with two gin and tonics last night, this morning it was clear that Wireshark would be the answer. Instead of spending hours trying to figure out why in the hell I was getting that message, I just fired Wireshark up and followed the TCP stream going back and forth from my app to the server. That told me that the server was returning a 301 Temporary Redirect because there was no endpoint at “http://my_url/without_an_endingslash” but that there was an endpoint listening at “http://my_url/without_an_endingslash/” and so I was being redirected there.
2 minutes using a great tool and I had the answer. I love days like this, rare though they are.