Data Bondage in WPF presentation at Toronto Code Camp

My final presentation in my April World Speaking tour was at the Toronto Code Camp this afternoon. As always, the code camp was a huge success. The efforts of many people went into making it so, but the organization was top notch.

As part of the lead-up to my presentation, Joey de Villa made good on a promise to wear Microsoft branded assless chaps. And he even regaled the crowd with his version of Hit Me With Your Best Shot, a choice completely in character with the theme of the presentation.

As for the presentation, it went very well. Something like 70-80 people where there and I was pleased by the questions that were asked. I have always preferred an interactive audience because it means that they are probably listening. :)

As I promised at the end of the presentation, here are links to the slides and demos. Any questions are most welcome.

Slides: here

Demos: Download

Update: For those who want a more complete story surrounding the title of the presentation and the assless chaps references, check out Joey's blog post here.

Data Bondage in WPF Demo Code

This is the demo code used in the Toronto Code Camp 2009 presentation entitled "Data Bondage in WPF"

Never Test Alone – Presentation at KWSQA Testing Conference

I finished presentation four of my April World Tour of the GTA earlier today. It was actually a co-presentation with Deb Forsyth and I was basically code-monkey and the 'developer’ that she could point to with here ‘bad developer’ stories. This was an unusual conference for me, in that I was a lone developer in a room full of testers. Daniel never had it so bad with the lions. :)

Anyway, as I mentioned in the presentation, the slides are now available for download at the following link. As always, questions are welcomed.

Slides – Download

Never Test Alone - KWSQA Presentation

This is the slide deck from the Never Test Alone presentation that I did with Deb Forsyth at the KWSQA conference.

Dropping Cookies in IE7

I was asked an unusual question yesterday about cookies, Silverlight and WCF. The scenario was that a Silverlight application was being used in a consumer-facing situation. The application itself communicates with the server using WCF. The service which is the target of the communication uses ASP.NET Authentication to authenticate the user. It’s an implementation detail (but critical to this post) that the method of storing the authentication token is a cookie called .ASPXAUTH.

In a normal (that is, working) scenario with Silverlight, the credentials are sent to the server and an .ASPXAUTH cookie is returned. The browser strips off the cookie and stores it. On any subsequent requests, Silverlight creates a request and sends it the the server through the browser’s networking API. The browser is responsible for determining which, if any, cookies should be send with the request and adding them to the outgoing header. In other words, the Silverlight application has no specific knowledge of or interaction with the .ASPXAUTH cookie.

As you would expect, this mechanism works the vast majority of the time. If it didn’t, I think it would have been a significant story long before now. But my questioner was running into a situation where the Silverlight application was unable to communicate with the server even after authentication was performed. What’s worse, this behavior was only happening on IE7. When Silverlight was run through Firefox, it worked exactly as it was supposed to.

The diagnostic step in a situation like this is to use Fiddler (or whatever your favorite TCP trace application is) to view the raw messages. And what was seen is that although the authentication response had the .ASPXAUTH cookie in it, any requests sent back to the server after authentication did not. Given when I’ve already explained about the processing of cookies with Silverlight requests, this eliminates the Silverlight application as the most likely culprit. But it also makes one scratch your head, as we can be pretty certain it’s not a widespread failure of IE7 to process cookies.

The answer likes in a strange bug in IE7. It turns out that if a domain name has a underscore in it, IE7 doesn’t persist the cookies. Let me repeat that, because it’s such a bizarre sounding problem. In IE7, if the domain name has an underscore (‘_’) in it, then any cookies returned from the domain will not be persisted. Which also means that subsequent requests will be ‘cookie-free’.

I’m guessing that most domain names don’t have an underscore, which is why this bug didn’t get widespread notice. In this particular case, the domain was one used for development, which would keep the problem from being a production issue. But I have no reason to believe that the bug would be restricted to a local problem. Deploy a ‘underscored’ domain name to the public internet and no authentication, shopping carts or other state information can be saved.

Fortunately, the solution was a simple one. If the domain name in the endpoint configuration is replaced with the raw IP address, IE7 is more than happy to save the cookie. I wouldn’t be surprise if an entry in your local hosts file would have the same effect. And the final solution would be to have your domain administrator create a DNS Alias entry…one that doesn’t have an underscore, of course.

Code Contracts at Toronto VB User Group

On Wednesday past, I did a Code Contracts presentation to the Toronto Visual Basic User Group. It was a continuation of my whirlwind ‘April Presentation Tour’, in that it was my third presentation in a week and the third of five that I’m doing in April. Tee shirts for the April Presentation Tour were available for sale from vendors as you left the arena

I have posted the slides and the source code to the following links:

Slides: Here

Source Code: Here

If you have any questions, please feel free to drop me a comment or an email message.

Code Contracts in .NET Demo Code

This is the demonstration code used during my Code Contracts in .NET presentation for TVBUG.

What’s New in Silverlight 3 at the Toronto Silverlight User Group

This past Thursday, I had the opportunity to present on Silverlight 3 to the Toronto Silverlight User Group. It was my first time presenting to the group and I was impressed by the number of attendees (I would say 30-40) who managed to hang around on the Thursday evening before a long weekend.

As promised, I have posted the slides and the source code to the following links:

Slides: Here

Source Code: Here

If you have any questions, please feel free to drop me a comment or an email message.

What's New in Silverlight 3 Demo Source Code

Contains the source code for the demos from the What's New in Silverlight 3 presentation

Catastrophic Failure While Installing an Out-of-Browser Silverlight Application

While working on one of the demos for my upcoming Toronto Silverlight User Group presentation, I ran into a catastrophic failure. Actually, the starting point for the problem was that when I right-clicked on the Silverlight application and selected the installation option, nothing happened. No errors, no warnings, but also no results.

While trying to figure out the problem, I when to the more direct method of installation by programmatically calling Application.Current.Detach(). When this statement was hit, an exception was thrown with the following beautiful details.

System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Application_Detach(Application app)
   at System.Windows.Application.Detach()
   at LocalConnectionDemo.MainPage.Button_Click(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

As you might guess, this is not particularly useful in the debugging process. After a fair bit of effort, I discovered the solution. I happen to be using a PNG file as the icon for the application. When the PNG file is added to the project, the Build Action is automatically set to Resource. When you change the Build Action to Content, the problem goes away.

Also, the same exception is thrown if the file used as the out-of-browser icon is not present at the indicated location.

I’m hoping that the exception becomes a little more useful as Silverlight 3 moves through the beta process.