Geeks With Blogs
Shahed's blog Sharing my thoughts and work

Just installed the runtime and Silverlight Tools for Visual Studio 2008. You can find the necessary tools here. The beta 1 now has a good set of controls including Data Grid, cool!

To run the Silverlight 1.1 Alpha projects in Beta 1, you need to manually modify few things.


First, if you try to open the old projects in VS 2008 after installing the latest bits, you will get the following error message:

"Unable to read the project file '... .csproj'. ... The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\Silverlight\Microsoft.Silverlight.Csharp.targets" was not found."

Just open the project file with notepad and replace the <import> node value.

Old: <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\Silverlight\Microsoft.Silverlight.Csharp.targets" />

New: <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" />

Save the project file and now you can load it in Visual Studio. Now that you have the projects opened, if you expand the Reference node you will see this:

image

You need to delete agclr, system.silverlight and system.Xml.core from the reference list. Then add the new assemblies: System.Windows, System.Windows.Browser, System.Windows.Controls and System.Windows.Controls.Extended.

image 

Ok, lets do a rebuild now. Don't worry if you get a long list or errors. Here is a quick list the things you may just do find and replace:

  • There is a PointCollection class now. So if you have List<Point> then you can change it to PointCollection
  • For Keyboard events (i.e. KeyUp, KeyDown...) replace KeyboardEventArgs with KeyEventArgs
  • System.Windows.Browser.Serialization is moved, so you need to block //using System.Windows.Browser.Serialization
  • Previously, in xaml we used to write x:Class="SilverlightApplication1.Page;assembly=ClientBin/... .dll". Now we don't need to mention the assembly part. Just write x:Class="SilverlightApplication1.Page"
  • For mouse events (i.e. MouseEnter, MouseLeave...) replace the EventHandler with MouseEventHandler and for MouseLeftButtonUp/MouseLeftButtonDown change it to MouseButtonEventHandler

Now, look into the web service. Lets assume you have a service named MyService and you have added the necessary web reference. The Silverlight 1.1 Alpha would generate a MyService class and to call any method asynchronously you would probably write something like this:

void Test()
{
    MyService service = new MyService();
    AsyncCallback callback = new AsyncCallback(FooCallback);
    Core.BeginFoo(parameter, service);
}

FooCallback(IAsyncResult result)
{
    MyService service = result.AsyncState as MyService;
    service.EndSyncCommand(result);
}

In silverlight 2 beta 1, you need to do this slightly differently. It will generate a MySerciceSoapClient class. So, you may write something like this:

void Test()
{
    MyServiceSoapClient service = new MyServiceSoapClient();

    service.FooAsync();

    service.FooCompleted += new EventHandler<FooCompletedEventArgs>(service_FooCompleted);
}

void service_FooCompleted(object sender, FooCompletedEventArgs e)
{
    ...
    ...
}


In addition to the above mentioned points, you should also look into the new App.xaml.cs file where you can handle any application wide exception as well as application startup and exit codes.

Posted on Wednesday, March 5, 2008 12:25 PM Silverlight | Back to top


Comments on this post: Converting Silverlight 1.1 Alpha projects to Silverlight 2 Beta 1

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Shahedul Huq Khandkar | Powered by: GeeksWithBlogs.net