Updating a Silverlight 2 Application from Beta 1 to Beta 2

On my system, I had Silverlight 2 Beta 1, Visual Studio 2008, Expression Blend 2.5 March Preview, and the Visual Studio Tools for Silverlight 2 Beta 1.  I did not uninstall anything.

  1. I installed the Microsoft Silverlight Tools Beta 2 for Visual Studio 2008
  2. I installed Expression Blend 2.5 June 2008 Preview
  3. I started Visual Studio 2008 and opened a Silverlight 2 Beta 1 project I was working on.  Immediately I got this message to upgrade the project:
    image
  4. I rebuilt the project and got three compiler errors:
    image 
  5. I solved the WebClient error by referencing the System.Net library and then built again. That resulted in a few more errors:
    image
  6. The GetStylusPoints errors (1 & 3) were a change in the API for pen input.  If you used MouseButtonEventArgs.GetStylusPoints(), now you should use MouseButtonEventArgs.StylusDevice.GetStylusPoints()
  7. The AddStylusPoints error (2) was also a change in the API for pen input.  If you used StylusPointCollection.AddStylusPoints() now you should use StylusPointCollection.Add().
  8. To solve the DownloadProgressEventHandler error (4 & 5), I used the generic event handler EventHandler<DownloadProgressEventArgs> instead of the DownloadProgressEventHandler class.
  9. To solve the DownloadProgress error (6), I changed my code to use the DownloadProgressEventArgs.Progress instead of the Image.DownloadProgress API.
  10. On the HTML page, I changed the installer URL within the object tag to https://www.microsoft.com/silverlight/handlers/getsilverlight.ashx?v=2.0
  11. On the HTML page, I changed the <object> type attribute to application/x-silverlight-2-b2
  12. I then built and ran it and it worked! A total of 15 minutes to move the application from Silverlight 2 Beta 1 to Beta 2.

Here's what the application does:

It uses the Photobucket API to search for images and videos hosted on Photobucket. I am working on a Silverlight library for Photobucket and this is my first example application using it. Search for images and/or video using the search box on the left. When you get results drag them onto the yellow surface and you can draw on top of them. No saving yet, though. And if you are wondering about the video, it's Flash. The videos on Photobucket are hosted in Flash but the API returns the URL of a player so using the HTML bridge in Silverlight, I can create an <iframe> and manipulate it from mouse events in Silverlight:

                 if (media.MediaType == "video")
                {
                    url = media.Thumb;

                    m_videoFrame = HtmlPage.Document.CreateElement("iframe");

                    m_videoFrame.SetAttribute("src", media.Url.ToString());
                    m_videoFrame.SetAttribute("width", "300");
                    m_videoFrame.SetAttribute("height", "300");
                    m_videoFrame.SetStyleAttribute("position", "absolute");
                    m_videoFrame.SetStyleAttribute("z-index", "2");
                    double left = e.GetPosition(null).X - m_offset.X;
                    double top = e.GetPosition(null).Y - m_offset.Y;
                    m_videoFrame.SetStyleAttribute("left", Math.Floor(left).ToString() + "px");
                    m_videoFrame.SetStyleAttribute("top", Math.Floor(top).ToString() + "px");

                    HtmlPage.Document.Body.AppendChild(m_videoFrame);
                }

The application (https://xmldocs.net/sketchbook) is a bit rough around the edges but I'm using it to experiment with Silverlight 2 and my Photobucket-Silverlight library.

 image

I'm still looking for people to help me build out the Photobucket-Silverlight library so please contact me if you're interested.