Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Low-Cost High Availability: Simple Database Monitoring in a Windows Environment : Page 5

The .NET Framework 2.0 and Visual Studio 2005 make it easy to create a basic but extensible database-monitoring solution without a lot of complexity or coding.


advertisement

Creating a Setup Project

To install a Windows Service project, add a Setup Project to the solution:
  1. In the Solution Explorer, add a new Setup and Deployment project to the solution. Give it a meaningful name such as SetupMonitorService (see Figure 6).

    Click to enlarge

    Figure 6. Adding a Setup and Deployment Project to the Solution
  2. In the Solution Explorer, right-click SetupMonitorService and select Add | Project Output (see Figure 7).

    Click to enlarge

    Figure 7. Adding Project Output from the Service Project to the Setup Project
  3. On the Add Project Group Output dialog box, confirm that you have Primary output selected and click OK (see Figure 8).



    Click to enlarge

    Figure 8. Add Project Output Group Dialog Box
  4. In the Solution Explorer, right-click the setup project, select View, and then select Custom Actions (see Figure 9).

    Click to enlarge

    Figure 9. Selecting Custom Actions
  5. To add a custom action, right-click Custom Actions and select Add Custom Action. The "Select Item in Project" dialog box appears. Double-click the Application Folder (see Figure 10).

    Click to enlarge

    Figure 10. Select Item in Project Dialog Box Superimposed Over the Custom Actions Editor
  6. Select Primary output from MonitorService (Active) and click OK (see Figure 11).

    Click to enlarge

    Figure 11. Select Primary Output from MonitorService (Active) and Click OK
  7. Build the setup project by right-clicking it in Solution Explorer and selecting Build (see Figure 12). Resolve any errors and save your solution.

    Click to enlarge

    Figure 12. Building the Setup Project
  8. Install the service by right-clicking the setup project and selecting Install (see Figure 13).

    Click to enlarge

    Figure 13. Invoking the Installer
  9. Since you specified that the service will execute in the context of a user account, the installer prompts you for the user's credentials (see Figure 14).

    Click to enlarge

    Figure 14. Set Service Login Dialog Box Superimposed Over the Installer Window
  10. Although the service is set to start automatically, it does not do so after installation. It will start automatically after a reboot. You could add code to make it start automatically after installation, but to keep things simple, use the Services applet from Administrative Tools to start the service initially (see Figure 15).

    Click to enlarge

    Figure 15. Select the Monitor Service and Click Start
  11. You can stop the service and change entries in the MonitorService.exe.config file and restart the service to have it use the new values, such as IntervalMsec. To force a connection failure during testing, change the name of the server in a connection string to an invalid server name.

Power and Ease of Use in .NET 2.0

You have seen some of the .NET Framework 2.0's powerful yet easy-to-use features in action:
  • When you use its ConfigurationManager class with an application configuration file, you eliminate the need to recompile after changing application parameters and settings, which reduces brittleness.
  • DbFactory classes further reduce brittleness by making data-access code provider agnostic.
  • Generic lists simplify code by providing simple-to-use abstractions in code.
  • The System.Net.Mail namespace greatly simplifies the task of sending mail from an application.
  • Windows Services allow durable applications to be built.



John Paul Cook is a database and systems architect in Houston, Texas, and is a Microsoft MVP.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap