Today I had to migrate a Silverlight Alpha 1.1 project to Silverlight 2 beta 1 for a client.
As we had to expect there are a lot of changes!
First thing to notice: after installing Silverlight 2 Tools for Visual Studio 2008 you won't be able to open your Silverlight 1.1 projects in VS2008, you have to migrate.
The best way is to create a new Silverlight application and copy your old files there, then this article will be a huge help to fix your issues:
MSDN: Breaking Changes in Silverlight 2
Here are some of the changes I had to deal with:
- HtmlDocument.GetElementByID -> HtmlDocument.GetElementById
- System.Windows.WebApplication.RegisterScriptableObject -> HtmlPage.RegisterScriptableObject
- System.Windows.WebApplication -> System.Windows.Application
- [Scriptable] attribute -> [ScriptableType] for class, [ScriptableMember] for methods
And the one who surprised me the most: Web Services
It is said that you have to regenerate your Web Service client proxies, but when looking for "Add Web Reference" in VS2008, I don't find it!! I just have "Add Service Reference" which is WCF for me. For ASP.NET 3.5 projects, you have both "Add Service Reference" for WCF and "Add Web Reference" for Web Services.
I know that Silverlight 2 supports both WCF and Web Services, so where the hell is "Add Web Reference" ??
Answer is: use "Add Service Reference"!
Calling a Web Service in Silverlight 2 is very similar to calling a WCF Service, that means that you have to specify binding and endpoint.
Second surprise: all web service calls must be asynchronous!
You must implement the async pattern, that surprised me at first, but now I found that this is not a bad thing and just requires 2 or 3 lines of code, so get used to it!
For syntax and code details I invite you to read this very good post :
Calling web services with Silverlight 2