Hello everyone,
I just want to re-write this VB.Net code using ArcGIS Server 10.2. It works fine in ArcGIS Server 10.0 but it fails in ArcGIS Server 10.2:
Dim gputilities As IGPUtilities = New GPUtilitiesClass()
Dim myResult As Boolean = True
' Declare server context variables
Dim mapServerContext As IServerContext = Nothing
Dim agsServerConnection As ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection = Nothing
Dim featuresCount As Integer
Try
Dim username As String = ConfigurationManager.AppSettings("username")
Dim password As String = ConfigurationManager.AppSettings("password")
Dim domain As String = ConfigurationManager.AppSettings("domain")
Dim hostname As String = ConfigurationManager.AppSettings("hostname")
Dim mapservice As String = ConfigurationManager.AppSettings("mapservice")
' Connect to ArcGIS Server
Dim adfIdentity As New ESRI.ArcGIS.ADF.Identity(username, password, domain)
agsServerConnection = New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(hostname, adfIdentity)
agsServerConnection.Connect()
If (Not agsServerConnection.IsConnected) Then
agsServerConnection.Dispose()
Return False
End If
' Get a reference to the server object manager to use in creating server objects
Dim serverObjectManager As ESRI.ArcGIS.Server.IServerObjectManager = agsServerConnection.ServerObjectManager
' Create a server context for and get a reference to the BloomfieldTownship map service. We will
' use this to access map information and query features.
mapServerContext = serverObjectManager.CreateServerContext(mapservice, "MapServer")
Dim mapServer As ESRI.ArcGIS.Carto.IMapServer2 = TryCast(mapServerContext.ServerObject, ESRI.ArcGIS.Carto.IMapServer2)
' Get a reference to the map service's server objects
Dim mapServerObjects As ESRI.ArcGIS.Carto.IMapServerObjects = CType(mapServer, ESRI.ArcGIS.Carto.IMapServerObjects)
Dim map As ESRI.ArcGIS.Carto.IMap = mapServerObjects.Map(mapServer.DefaultMapName)