Server Explorer


The Server Explorer window serves two purposes: It exposes various system services and resources that reside on your local machine and on remote machines, and it provides access to data connection objects. As with the other Visual Studio explorer windows, the systems, services, resources, and data connections are viewed in a graphical tree format. Systems appear under a top-level Servers node (your local machine will show up by default), and data connections appear under a top-level Data Connections node.

Note

The Server Explorer window content and configuration are not specific to a solution or project. Server Explorer settings are preserved as part of the IDE environment settings and are thus not subject to change on a per-solution (or project) basis.


A toolbar appears at the top of the Server Explorer window, providing one-click access to the Add Data Connection and Add Server functions (see Figure 5.6). You can also force a refresh of the window contents (a button is also provided to cancel the refresh because querying remote machines may be a lengthy process).

Figure 5.6. The Server Explorer window.


Note

The Express and Standard editions of Visual Studio do not have support for servers within the Server Explorer window; they are limited to data connections only. In fact, these versions of Visual Studio actually refer to this window as the Data Explorer window.


Data Connections

Data Connections represent a physical connection to a local or remote database. Through an established connection, you can gain access to and manipulate the various objects within a database. Each category of object will show up as a folder node under the Data Connections node. The tree items under each node allow you to directly interact with their physical database counterparts through a suite of designers and editors collectively referred to as Visual Database Tools. These tools are covered in depth in Chapter 15, "Working with Databases."

The following objects are exposed in the Server Explorer:

  • Tables

  • Views

  • Stored procedures

  • Functions

  • Synonyms

  • Types

  • Assemblies

In general, you can create new database objects, edit or delete existing ones, and, where appropriate, query data from a database object (such as a table or view).

Note

The level of functionality and the number of object types you can access through the Server Explorer depend on both the version of Visual Studio you are using and the version of the database you are connecting to. In other words, not all functions are supported across all databases. The Visual Database Tools interact most effectively with Microsoft SQL Server, although most basic functions are supported against a variety of other relational database.


Server Components

The Servers node in Server Explorer exposes a variety of 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 will be visible here as a server; to add other servers, right-click on the Servers node and select Add Server or simply click on the Connect to Server button in the Server Explorer toolbar. A dialog box will prompt you for a computer name or IP address for the server; this dialog box also supports the ability to connect via a different set of credentials.

Under the Servers node, the following component categories will appear as child nodes:

  • Event Logs

  • Management Classes

  • Management Events

  • Message Queues

  • Performance Counters

  • Services

Other component categories may 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 2005.

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 will automatically be 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 here are shown in Table 5.8.

Table 5.8. WMI Management Class Nodes

Title

WMI Class

Desktop Settings

Win32_Desktop

Disk Volumes

Win32_LogicalDisk

My Computer

Win32_ComputerSystem

Network Adapters

Win32_NetworkAdapter

Network Connections

Win32_NetworkConnection

NT Event Log Files

Win32_NTEventLogFile

Operating Systems

Win32_OperatingSystem

Printers

Win32_Printer

Processes

Win32_Process

Processors

Win32_Processor

Services

Win32_Service

Shares

Win32_Share

Software Products

Win32_Product

System Accounts

Win32_SystemAccount

Threads

Win32_Thread


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, in turn, each of these property groups will expose 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 eventing system on the server. These event queries are established through a dialog box (see Figure 5.7; 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 will appear.

Figure 5.7. Creating a Management Event query.


Message Queues

If message queuing is installed on the target server, the Message Queues node displays all of the available message queues, along with any messages currently residing in each queue.

Performance Counters

Every performance counter installed on the target computer can be viewed 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. The shortcut menu off each service is used to control the service: Continue, start, stop, and pause actions are all supported (see Figure 5.8).

Figure 5.8. A service shortcut menu.


Programming with Server Explorer

Beyond allowing 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. As an example, dragging the Application Log node (from Servers, Event Logs) onto an existing Windows form will create 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 could 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 drag-and-drop operations that are possible, along with their results.

Table 5.9. Server Explorer Drag and Drop

Under This Node

Dragging This

Does This

Event Logs

Event Log Category (for example, Application or System)

Creates a System.Diagnostics.EventLog component instance, configured for the appropriate event log

Management Classes

Management Class instance

Creates the appropriate WMI/CIMv2 component instance

Management Events

Management Event Query

Creates a System.Management.ManagementEventWatcher component instance

Message Queues

Message Queue instance

Creates a System.Messaging.MessageQueue component instance for the selected queue

Performance Counters

Performance Counter or counter instance

Creates a System.Diagnostics. PerformanceCounter component instance, configured for the appropriate counter

Services

Service

Creates a System.ServiceProcess.ServiceController, provisioned for the indicated service


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





Microsoft Visual Studio 2005 Unleashed
Microsoft Visual Studio 2005 Unleashed
ISBN: 0672328194
EAN: 2147483647
Year: 2006
Pages: 195

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net