Server Components

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:

Image Event Logs

Image Management Classes

Image Management Events

Image Message Queues

Image Performance Counters

Image 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.

Event Logs

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.

Management Classes

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.

Image

TABLE 5.8 WMI Management Class Nodes

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.

Management Events

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.

Image

FIGURE 5.11 Creating a Management Event query.

Message Queues

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.

Performance Counters

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.

Services

Each installed service is enumerated under the Services node.

Programming with Server Explorer

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.

Image

TABLE 5.9 Server Explorer Drag and Drop


Note

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.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset