Share Intelligence

Where SharePoint meets Business Intelligence

June 2008 - Posts

Microsoft Silverlight 2 Beta 2 Released & Upgrading

Last Monday at TechEd, it was announced that Silverlight 2 Beta 2 would available later in the week.  Well, it hit the streets late last Friday.   So I decided to upgrade my NFL Free Agency app to the new beta.  I got it upgraded but it wasn't a smooth process.

 

My first order was to download the new bits.  I downloaded the silverlight chainer which contains the run-time, SDK, KB950630, KB950632, and the Tools for VS 2008.  I also downloaded the June preview of Expression Blend 2.5.  Once, I downloaded them I launched the silverlight chainer and it when through the install without a hitch.  Of course, I should have know that was too easy.  I tried opening the Free Agency project, low and behold an error.

SLB2_SP1Bx_OpenProject

So let me try a new project.  Nope that didn't work either.

I tried to uninstall everything and reinstalling along with rebooting.  Nothing.  After a little digging I came across a post, Upgrading to Silverlight Tools Beta 2 and Visual Studio 2008 SP1 Beta, which described the problem I was having.  Unfortunately, he stated that as long as I didn't have the beta of VS 2008 SP1 installed it should work fine.  That the installer should install KB949325 so the new Silverlight bits would install correctly.  I check through Control Panel and I did not see hotfix installed.  I then remembered, I had to manual install the bits for beta 1.  So, I thought I would manually uninstall KB949325.  What I thought was the correct command to uninstall the hotfix was actually a command to uninstall Visual Studio 2008.  After MSDN download and install of a fresh copy of Visual Studio, I tried to install the chainer again.  This time everything when smoothly along with the install of Expression Blend.

I finally opened my project, it prompted that it was built with an earlier beta and do I want to update the project.  Of course I answered yes and everything looked good. 

Next, I tried to build the project and there were errors.  So I started to go through the errors along with the list of breaking changes between Beta 1 and Beta 2.  

DependencyProperty.Register and DependencyProperty.RegisterAttached functions now take PropertyMetadata as a parameter instead of PropertyChangedCallback

The first change I came accross was with a lot of my properties on my custom Silverlight controls.  Most were setup as dependency properties.  The method now took a PropertyMetadata type instead of a PropertyChanged Callback.  The easy way to fix was to wrap the PropertyChangeCallback class with a PropertyMetadata class. I noticed I really wasn't using the Callbacks anyway so I set them to null and that fixed that issue.

ToolTip is being hidden and can no longer be used directly—ToolTips can now only be added to controls through the ToolTipService

The next problem I had was with the close button.  It had a tooltip set for it.  The Tooltip class is now hidden and you have to set the Tooltips through the ToolTipService.

this.FindName vs this.Layout.FindName

Those were the only design time errors I ran into.  Not too bad.  Now to fire the app up.  I launch the app in debugging mode, I hit a null reference exception when it tries to set the logos for the team list on the left side.  

Canvas teamCanvas = this.FindName(selectedTeam.ToString()) as Canvas; 

The FindName was no longer working.  It used to be able to search through all the UI Elements including sub controls.  However, it no longer worked.  I changed it to the following and it was able to find the canvas.

Canvas teamCanvas = this.Layout.FindName(selectedTeam.ToString()) as Canvas; 

ActualHeight vs Height

I launched the app again and it loads.  However, all the player controls are stacked on top each other in the middle.  The layout function is not working correctly.  Back into the code I go.  The application uses a example player control at run-time to determine a standard player controls dimensions. 

double playerLayoutSize = playerCount * example.ActualHeight + spacerCount * 10;

When debugging the preceding ling the ActualHeight now returned 0.  Height now seems to return the correct value of 40.  So I changed all the lines to use Height and Width properties for the example control.

double playerLayoutSize = playerCount * example.Height + spacerCount * 10;

Once I made all these changes everything worked correctly.  I uploaded my new XAP file to my hosting provided.  I also uploaded the BIN directory which contains all the new Silverlight controls and libraries. 

Overall, my upgrade experience was not the worse one I've ever done, but wasn't the smoothest either.

More Posts