Initializes a new ServiceLayer object and connects the layer to the specified ArcGIS Server image service.

Namespace:  ESRI.ArcGISExplorer.Mapping

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public static ServiceLayer OpenImageServer(
	Uri url,
	string service
)
Visual Basic (Declaration)
Public Shared Function OpenImageServer ( _
	url As Uri, _
	service As String _
) As ServiceLayer

Parameters

url
Type: System..::.Uri

A Uri object which represents a Uniform Resource Identifier and consists of a string used to identify the base URL of the image service on the Internet.
service
Type: System..::.String

The name of the image service on the server in the url parameter.

Return Value

A ServiceLayer object connected to the specified ArcGIS Server image service.

Remarks

Use this method to both instantiate a ServiceLayer and connect the layer to an ArcGIS Server image service by specifying the base URL and the service name. In contrast to the Connect method, an exception will be thrown if the specified service cannot be accessed.

Version Information: This member is supported from version 2.0.0.1500.

Examples

The code below demonstrates how to both create and connect a ServiceLayer to an ArcGIS image service in a single call using the static OpenImageService method specifying the base URL of the machine exposing the image service, and the image service name. The new layer is then added as the first item in the Map, using the AddFirst method.
CopyC#
{
  try
  {
    // Create and connect to the Portland Cascade landsat image service on an ESRI sample server.
    ServiceLayer sl = ServiceLayer.OpenImageServer(new Uri(@"http://sampleserver3.arcgisonline.com/ArcGIS/services"),
                                                    @"Portland\CascadeLandsat");

    //Add layer to the map
    ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.ChildItems.AddFirst(sl);
  }
  catch (ESRI.ArcGISExplorer.ConnectionException ex)
  {
    System.Diagnostics.Debug.Print(ex.Message);
  }
}
CopyVB.NET
Try
  ' Create and connect to the Portland Cascade landsat image service on an ESRI sample server.
  Dim sl As ServiceLayer = ServiceLayer.OpenImageServer(New Uri("http://sampleserver3.arcgisonline.com/ArcGIS/services"), _
                                                    "Portland\CascadeLandsat")

  ' Add layer to the map
  ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.ChildItems.AddFirst(sl)
Catch ex As ESRI.ArcGISExplorer.ConnectionException
  System.Diagnostics.Debug.Print(ex.Message)
End Try

Exceptions

ExceptionCondition
ESRI.ArcGISExplorer..::.ConnectionExceptionConnection failed. Check the Message and InnerException properties of the ConnectionException for more information about the reasons for the failure.

See Also