Silverlight and WCF for Beginners

In this article we will learn:

  • How to create Silverlight applications
  • How to create simple WCF services
  • How to deploy solutions on Arvixe


To work with Silverlight 4 in Visual Studio 2010, you will need to download and install  Silverlight Tools 4

Create project

Open Visual Studio and create a Silverlight Application

The New Project wizard prompts you to create our site for Silverlight applications

Create Simple WCF Services

Right click on Web project and select the “Add -> New Item…” menu


public interface IDateTimeService
      DateTime GetDateTime();


public class DateTimeService : IDateTimeService
      public DateTime GetDateTime()
            return DateTime.Now;


<?xml version=”1.0“?>



      <compilation debug=”truetargetFramework=”4.0” />

      <customErrors mode=”Off“/>





            <behavior name=””>

               <serviceMetadata httpGetEnabled=”true” />

               <serviceDebug includeExceptionDetailInFaults=”true” />




      <serviceHostingEnvironment multipleSiteBindingsEnabled=”true” />



Click Add Service Reference next:

In the “Add Service Reference” dialog window, press “Discover” button and select service.


public partial class MainPage : UserControl
      DateTimeServiceClient proxy;

      public MainPage()

            proxy = new DateTimeServiceClient();
            proxy.GetDateTimeCompleted += (sender, e) =>
                  textBlockDateTime.Text = e.Result.ToString();

      private void Button_Click(object sender, System.Windows.RoutedEventArgs e)

The coding is now over. Press F5 to run solution.


Publish the Web project to file system first:


Upload the published site via FTP to In Web Site Control Panel, on the “Extensions” page, choose ASP.NET version “4.0”. Also, specify BlogArvixeCom.UserNT.WCFTestPage.aspx as default document on the “Home Folder” page. That seems to be all, but do not be surprised if clicking on the button “Server side time” causes nothing to happen. The file ServiceReferences.ClientConfig file is configured to work on localhost. All you need to do is set the correct endpoint address.


Source code

Tags: , , , , | Posted under 3rd Party Software, Programming/Coding | RSS 2.0

6 Comments on Silverlight and WCF for Beginners

  1. javea65 says:

    Must be remember in the website, just the WFC endpoint, change to wshttpbinding to basicHttpBinding.

  2. javea65 says:

    I forgotten.. is the web.config where the changes…

  3. Andrew Ivanov says:

    In my approach used basicHttpBinding by default. Of course you can configure bindings in web.config. But this is beyond the scope of this article.

  4. says:

    Setting Proxy

  5. Cool! Thanks for this interesting post!

  6. Penni says:

    Heya i’m for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you helped me.

Leave a Reply

Your email address will not be published. Required fields are marked *