The Servers node in Server Explorer exposes various remote or local services and resources for direct management or use within a Visual Studio project. In essence, it is a management console for server-based components. By default, your local machine is visible here as a server; to add other servers, right-click the Servers node and select Add Server or click the Connect to Server button in the Server Explorer toolbar. A dialog box prompts you for a computer name or IP address for the server; this dialog box also supports the capability to connect via a different set of credentials.
Under the Servers node, the following component categories appear as child nodes:
Event Logs
Management Classes
Management Events
Message Queues
Performance Counters
Services
Other component categories might also choose to register for display under the Servers node; the preceding list, however, represents the default, out-of-the-box functionality provided by Visual Studio 2015.
Under the Event Logs node, you can administer the separate application, security, and system event logs for the connected server. This includes clearing event log entries or drilling into and inspecting individual event log entries. Highlighting an event log or event log entry causes its properties to display in the Visual Studio property window, enabling you to view and edit their values. If you drag and drop one of the event logs into a project, a System.Diagnostics.EventLog or System.Diagnostic.EventLogEntry component instance is automatically created.
The items under the Management Classes node represent various Windows Management Instrumentation (WMI) classes. Each of these classes maps to a logical or physical entity associated with a server. The available classes are shown in Table 5.8.
A thorough discussion of WMI is beyond the scope of this chapter and this book; in summary, however, each of these nodes exposes various WMI class property groups (such as precedents, antecedents, settings, dependents, and so on), and, in turn, each of these property groups exposes a span of commands, enabling you to directly affect a resource on the server.
One simple example of how you might use this capability is to set access information for a share exposed on a remote server. When you expand nodes in the Server Explorer down to the share (via the Disk Volumes node), access to the share information is gained via the shortcut menu on the share. In this example, you would select the SetShareInfo action, which initiates a WMI dialog box allowing you to change various share attributes such as the description and maximum allowed users.
The Management Events node contains a list of event queries; essentially, these are “listeners” that you establish to periodically poll the WMI event system on the server. These event queries are established through a dialog box. (See Figure 5.11; you launch the dialog box by selecting Add Event Query on the shortcut menu.) When an event is created, a child node to the Management Events node is created, and under this node, actual event instances appear.
If message queuing is installed on the target server, the Message Queues node displays all the available message queues, along with any messages currently residing in each queue.
You can view every performance counter installed on the target computer in the Performance Counters node. Each performance counter is displayed within its category. Performance counter instances, if available, are also displayed.
Each installed service is enumerated under the Services node.
Beyond enabling you to examine and manipulate data connections and server resources, the Server Explorer serves another task: by dragging and dropping items from the Server Explorer onto a Visual Studio design surface, you can quickly create components in code that directly reference the item in question. For example, dragging the Application Log node (from Servers, Event Logs) onto an existing Windows form creates a System.Diagnostics.EventLog component instance that is preconfigured to point to the application log. You can then immediately write code to interact with the event log component. You can use the same process to quickly embed message queue access into your application or read from/write to a performance counter. Table 5.9 lists the various possible drag-and-drop operations, along with their results.
Data connection items in the Server Explorer cannot be dragged onto a design surface. For more information regarding drag-and-drop development of database solutions, see Chapter 13.