can´t see mapserver layer

Discussion created by vickarasu on Apr 17, 2011
Latest reply on Apr 18, 2011 by vickarasu
I need to add a layer from an ArcGis Server into an AxMapContol and the problem is that the layer is added but no features are seen in the map.
I have used the following code, taken from de EDN, with no errors. Any idea would be useful. Thank you in advance

Public Sub AddMapServerLayer()

  Dim pMxDoc As IMxDocument
  Dim pMap As IMap
  Dim pAV As IActiveView
  Dim pAGSServerConnectionFactory As IAGSServerConnectionFactory
  Dim pProps As IPropertySet2
  Dim pAGSConnection As IAGSServerConnection
  Dim pEnumSOName As IAGSEnumServerObjectName
  Dim pSOName As IAGSServerObjectName
  Dim pName As IName
  Dim pMapServer As IMapServer
  Dim pMSLayer As IMapServerLayer

  ' connect to the GIS server
  Set pAGSServerConnectionFactory = New AGSServerConnectionFactory
  Set pProps = New PropertySet
  pProps.SetProperty "machine", "doug"
  Set pAGSConnection = pAGSServerConnectionFactory.Open(pProps, 0)
  'Get the MapServer
  Set pEnumSOName = pAGSConnection.ServerObjectNames
  Set pSOName = pEnumSOName.Next
  Do Until pSOName Is Nothing
    If pSOName.Name = "GDBRaster" Then Exit Do
    Set pSOName = pEnumSOName.Next
  If pSOName Is Nothing Then Exit Sub

  Set pName = pSOName
  Set pMapServer = pName.Open
  'Create new layer
  Set pMSLayer = New MapServerLayer
  pMSLayer.ServerConnect pSOName, pMapServer.DefaultMapName
  'Add layer to map
  Set pMxDoc = ThisDocument
  Set pMap = pMxDoc.FocusMap
  Set pAV = pMap
  pMap.AddLayer pMSLayer
End Sub