A Walk-Through on “Silverlight RIA Service Toolkit” New Feature: WCF Client Proxy Auto Generation/Updating for WCF Core Service
After you install Silverlight RIA Service Toolkit RC, you will see a new feature available as highlighted in the snapshot below.
This feature enables the similar code generation for WCF Core services as WCF Domain services. The client proxy code and configuration will be automatically generated or updated when the solution is being built.
Let’s do a quick walk-through to better understand this feature.
WCF Client Proxy Code Auto Generating/Updating
Step 1: We create a Silverlight application using the “Silverlight Application” template, with “Enable Silverlight RIA service” option selected. The “SilverlightApplication15” solution is created which composes of “SilverlightApplication15” project as client and “SilverlightApplication15.Web” project as server.
Step 2: We add the “Silverlight-enabled WCF Service” item to the “SilverlightApplication15.Web”.
Step 3: We build the solution. We select “Show All Files” in “SilverlightApplication15” project in the Solution Explorer. We can notice a “GenerateWcfClientCode” folder is created composing of the WCF client proxy code named as “ServiceReference.cs”. We can also see the client configuration file is created named as “ServiceReferences.ClientConfig”.
Step 4: We can open the MainPage.xaml.cs file and write the client code to invoke the service.
If we make changes to service code, the client code will be updated accordingly after we build the solution.
“Add Service Reference” can work well together with this feature in the same Silverlight solution.
Opt out of “WCF Client Proxy Code Auto Generating/Updating”
We can manually add “<DisableAutoServiceReference/>” property in the proj file of client projects to opt out of proxy auto generation/updating. For example:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
……..
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<LinkedServerProject>..\SilverlightApplication2.Web\SilverlightApplication15.Web.csproj</LinkedServerProject>
< DisableAutoServiceReference >true</ DisableAutoServiceReference >
</PropertyGroup>
Once we set this property to true, all the auto generated client proxy code and configuration will be removed after building the solution.
More Stories in MSDN Blogs
- #Azure Action – Community Newsletter – 9th May 2012
- Adding Touch support to a Windows 8 Metro Style App using HTML and JavaScript
- Help! Visual Studio 11 Beta Dark Theme incorrectly using White Background
- Microsoft TechTalk on Windows 8
- Connecting to WCF RIA Services in a Windows 8 Metro Style App using Upshot.js and Knockout.js
Other Feedables
Chicago News - home of the deep dish
Mens Health - Healthy Feeding
Going Green - All organic.
Music Maker Feeds - The Musicians Kitchen
2012 Feeds - news that's hard to swallow- more Feedables...