Creating a Silverlight 2.0 Application that Consumes a WCF Service
(Page 1 of 4 )
This is my second article in a series focusing on Silverlight 2.0 (beta 2) development using Visual Studio 2008. This article is for beginners who are quite new to Silverlight development and need a practical introduction to developing Silverlight applications which consume WCF services using Visual Studio 2008.
If you are new to Silverlight 2.0 development, please refer my first article in this series titled “Beginning Silverlight 2.0 Development Using Visual Studio 2008.”
If you want to learn about the WCF Service and the WCF Service Library, consider reading my WCF articles listed at http://www.aspfree.com/cp/bio/Jagadish-Chatarji.
In this article, we will create a new WCF Service and consume it using the Silverlight 2.0 application. Technically, we will have a Silverlight 2.0 Datagrid control consuming rows from a regular WCF Service.
My development machine is equipped with following environment:
Windows Server 2003 with SP2
IIS
SQL Server 2008
Visual Studio 2008 (comes with .NET 3.5) with SP1
Microsoft Silverlight Tools Beta 2 for Visual Studio 2008 (includes Silverlight, Silverlight SDK and Tools for VS 2008)
To make this article simple, I created a new database named “Sample” with the following table (“emp”) on my machine (Fig 01):

The entire source code for this article is available in the form of a free downloadable zip file. The solution was developed using Microsoft Visual Studio 2008 Team Edition (with SP1) with Microsoft SQL Server 2008 Developer Edition on Microsoft Windows Server 2003 Standard Edition (with SP3) with Silverlight 2.0 Beta 2. I didn’t really test it in any other environment. I request that you post in the discussion area if you have any problems in execution.
Developing WCF Service using Visual Studio 2008: Creating the project
Let us start our development with WCF Service.
Create a blank solution (DemoSln) as follows:
Go to File || New || Project.
At the top of the “New Project” dialog, make sure that you have selected “.NET Framework 3.5” as your target .NET version.
In the “Project Type” (left pane of “New Project” dialog), open “Visual Studio Solutions” in “Other Project Types.”
In the “Templates” (right pane of “New Project” dialog), select “Blank Solution.”
Provide “DemoSln” as the "Name," your own location, and click “OK.”
Add a new WCF Service Application as follows:
Go to File || Add || New Project (to the existing solution).
In “Add New Project,” make sure “.NET Framework 3.5” is selected at the top.
Open “Visual Basic” || “Web” in the “Project Types” list.
Select “WCF Service Application” as the template.
Provide “DemoEmpService” as the name (Fig 02) and click on “OK.”

Next: Configuring for Silverlight >>
More Windows Scripting Articles
More By Jagadish Chaterjee