Click here to Skip to main content
13,249,315 members (31,712 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 13 Sep 2010

WCF Services for Silverlight (No Configuration Required)

, 13 Sep 2010
Rate this:
Please Sign up or sign in to vote.
WCF Services for Silverlight without configuration in config file


This article shows how to develop configuration-less WCF Services for Silverlight client.


It is pretty complex to maintain the configuration part of WCF services, if more services are adding / modifying, very frequently.

It will be a better idea to develop a service library for our Silverlight client, without any configurations in the config file. The following class diagram says about such a library, which is the scope of this article.


Using the Code

The vital class in the above class diagram is SLServiceHost, which inherits from ServiceHost and overrides ApplyConfiguration method. There, you can implement our custom bindings and Meta data behaviour, MEX, etc.

Below is the code snippet:

protected override void ApplyConfiguration()

There is a custom service host factory, SLServiceHostFactory, which inherits from ServiceHostFactoryBase and creates the instance of our SLServiceHost.

In our custom service(MyService.svc), in the XAML, we set the factory and service code behind attributes as follows:

<%@ ServiceHost Language="C#"
Service="Silverlight.Services.MyService" %>

Run Silverlight.Services.Web application from VS2010. The port is set to 33333.

Now run your wcftestclient utility from VS command prompt and add the service and test.

Click to enlarge image

Points of Interest

  1. Service Library with no configuration in Web.Config
  2. Single Contract Interface, ISLService


  • 13th September, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Shine K Velayudhan
Architect Automation Anywhere
India India
Working as Lead Architect at Automation Anywhere.

You may also be interested in...


Comments and Discussions

GeneralVirtualServices Pin
Member 33316222-Sep-10 15:37
memberMember 33316222-Sep-10 15:37 
GeneralMy vote of 4 Pin
Nils B14-Sep-10 23:12
memberNils B14-Sep-10 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 13 Sep 2010
Article Copyright 2010 by Shine K Velayudhan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid