How-to: Use the Disconnected Service Agent (DSA) with CompositeWPF (Prism)
A popular demand in Codeplex forums the past weeks has been related to working under temporarily connected scenarios. The Disconnected Service Agent Application Block that has been shipped with the SCSF since the May 2007 version was specially designed for this type of scenarios. Damian Schenkelman wrote a blog post overviewing the DSA to answer some of these questions.
Now that the Composite Application Guidance for WPF has been released, the issue became whether it was possible to use the DSA with Composite WPF. Therefore we decided to spend some time migrating the Disconnected Service Agent QuickStart from SCSF to its equal in Composite Application Library.

You can get the sample by downloading the latest change set of the CompositeWPF Contrib source control.
Using DSA in a Composite WPF application
All the Offline Blocks (Disconnected Service Agent, Endpoint Catalog and Connection Monitor) shipped with SCSF - May 2007 and higher versions do not have dependencies on CAB/SCSF.
To be able to use those blocks in a Composite WPF application you can do the following:
- Add the following configuration to the App.config file to configure the connection monitor and select the data storage that will be consumed by the DSA:
<configuration> <configSections> <section name="ConnectionMonitor" type="Microsoft.Practices.SmartClient.ConnectionMonitor.Configuration.ConnectionSettingsSection, Microsoft.Practices.SmartClient.ConnectionMonitor" /> <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" /> </configSections> <connectionStrings> <add name="QueueDatabase" connectionString="YourConnectionString" providerName="YourProvider" /> </connectionStrings> <ConnectionMonitor> <Networks> <!– To check for internet connectivity–> <add Name="Internet" Address="http://www.google.com" /> </Networks> </ConnectionMonitor> <dataConfiguration defaultDatabase="QueueDatabase"> <providerMappings> <add databaseType="Microsoft.Practices.SmartClient.EnterpriseLibrary.SmartClientDatabase, Microsoft.Practices.SmartClient.EnterpriseLibrary" name="System.Data.SqlServerCe" /> </providerMappings> </dataConfiguration> </configuration>
- Set up the Request Manager by overriding the ConfigureContainer method of your application’s Bootstrapper class.
protected override void ConfigureContainer() { // Set up request manager. RequestManager requestManager = DatabaseRequestManagerIntializer.Initialize(); requestManager.StartAutomaticDispatch(); // Add the request queue to the Container. This queue will be used by service agents to enqueue requests. Container.RegisterInstance<IRequestQueue>(requestManager.RequestQueue, new ContainerControlledLifetimeManager()); // Add the connection monitor to the Container. It will be used to determine connectivity status and provide // feedback to the user accordingly. Container.RegisterInstance<IConnectionMonitor>(requestManager.ConnectionMonitor, new ContainerControlledLifetimeManager()); base.ConfigureContainer(); }
- Create an Agent service class that uses the IRequestQueue to define the offline behavior of your web service (in SCSF this is performed by the Create a Disconnected Service Agent recipe).
- Register an instance of your Agent class into your container. You can do this in your Module class.
public void Initialize() { RegisterTypesAndServices(); // Add your module views… } private void RegisterTypesAndServices() { Container.RegisterType<Agent>(new ContainerControlledLifetimeManager()); }
Now you are able to inject your service agent in your classes.
Enjoy.
[...] Disconnected Service Agent (DSA) with CompositeWPF. This sample created by Mariano Converti and Damian Schenkelman demonstrate how to use the Disconnected Service Agent (DSA) with CompositeWPF. For more information about this sample, see How-to: Use the Disconnected Service Agent (DSA) with CompositeWPF (Prism). [...]