Configuring the Connection Monitor Application Block
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
To use the Connection Manager Application Block, you must add configuration information to the application configuration file. This configuration information defines the logical networks and physical network adapters that you want to monitor. With the following configuration section example, the application block will monitor connection to two logical networks and one physical network adapter.
<ConnectionMonitor> <Networks> <add Name="Intranet" Address="http://contoso"/> <add Name="Internet" Address="http://www.microsoft.com"/> </Networks> <Connections> <add Type="WiredConnection" Price="1"/> </Connections> </ConnectionMonitor>
The application block defines the following values that you can use for the Type attribute of the physical network adapter configuration information:
- NicConnection. The application block uses the NicConnection class to monitor any network interface connection: for example, an Ethernet card or wireless adapter. This class provides the capability to detect if the application has a connection to a network.
- WiredConnection. The application block uses the WiredConnection class to monitor connectivity to Ethernet adapters.
- WirelessConnection. The application block uses the WirelessConnection class to monitor connectivity to wireless network adapters.
- DesktopConnection. The application block uses the DesktopConnection class to monitor connectivity to local services (you can manually set the connection state of this class).
In addition, you can specify a fully-qualified type name as the value for the Type attribute. This means you can use your own implementation to determine connection status for an adapter.
If the connection price is not relevant to your application, you can set the connection price to 0.
The following procedure describes how to configure the Connection Monitor Application Block for use in a smart client application.
To configure the Connection Monitor Application Block
- Define a configuration section for the application block in the application configuration file. To do this, add a <section> node to the <configSections> node of your App.config file, as shown in the following XML.
<configSections> <section name="ConnectionMonitor" type="Microsoft.Practices.SmartClient.ConnectionMonitor.Configuration.ConnectionSettingsSection, Microsoft.Practices.SmartClient.ConnectionMonitor" /> </configSections>
Note: You can specify any name for the configuration section. However, if you use a name other than "ConnectionMonitor," you must specify that section name when you instantiate the connection monitor service in your application code.
- Create the application block configuration section and define your logical networks. Configure each logical network inside a <Networks> node using an <add> element, as shown in the following XML. If you do not specify a connection type the ConnectionMonitorFactory will use a NicConnection (this type monitors any type of connection).
- If you want to monitor physical network adapters, add the configuration information for the network adapters inside a <Connections> element, as shown in the following XML.
- Optionally, specify the type name of the network status strategy to use to monitor the connection status of the logical network. To do this, add the StrategyType attribute to the <Networks> node. A network status strategy is a concrete implementation of the INetworkStatusStrategy interface. If you do not add the StrategyType attribute, the application block will use the type HttpPingStatusStrategy.