You first need to add two references:
Using ESRI. Arcgis.gisclient;
Using ESRI. Arcgis.datasourcesraster;
<summary>//ArcGIS Server service is invoked///</summary>//<param NA Me= "Sender" ></param>//<param name= "E" ></param> private void symbol varies with scale toolstripmenui Tem_click (object sender, EventArgs e) {//Get service object name Iagsserverobjectname Pserverobjectname = G Etmapserver ("Http://services.arcgisonline.com/ArcGIS/services", "esri_imagery_world_2d", false); Iname pName = (iname) pserverobjectname; Access Map Service Iagsserverobject Pserverobject = (iagsserverobject) pname.open (); Imapserver pmapserver = (imapserver) pserverobject; ESRI. ArcGIS.Carto.IMapServerLayer Pmapserverlayer = new ESRI. ArcGIS.Carto.MapServerLayerClass (); Connection Map Service Pmapserverlayer.serverconnect (Pserverobjectname, pmapserver.defaultmapname); Add Data layer Axmapcontrol1.addlayer (Pmapserverlayer as ILayer); Axmapcontrol1.refreSH (); }///<summary>///Get a map service, return to Iagsserverobjectname///</summary>//<param Name= "Phostorurl" ></param>//<param name= "Pservicename" ></param>//<param name= " Pislan "></param>///<returns></returns> public iagsserverobjectname getmapserver (strin G Phostorurl, String pservicename, bool Pislan) {//Set connection properties Ipropertyset Ppropertyset = new Pr Opertysetclass (); if (Pislan) Ppropertyset.setproperty ("Machine", phostorurl); else ppropertyset.setproperty ("url", Phostorurl); Open connection Iagsserverconnectionfactory pfactory = new Agsserverconnectionfactory (); Type Factorytype = Type.gettypefromprogid (//"esrigisclient.agsserverconnectionfactory"); Iagsserverconnectionfactory agsfactory = (iagsserverconnectionfactory)// Activator.CreateInstance (Factorytype); Iagsserverconnection pconnection = Pfactory.open (ppropertyset, 0); Get the image server. Iagsenumserverobjectname pserverobjectnames = pconnection.serverobjectnames; Pserverobjectnames.reset (); Iagsserverobjectname serverobjectname = Pserverobjectnames.next (); while (serverobjectname! = null) {if ((ServerObjectName.Name.ToLower () = = Pservicename.tolower ( ) && (Serverobjectname.type = = "MapServer")) {break; } serverobjectname = Pserverobjectnames.next (); }//Returns the object return serverobjectname; }
ArcGIS Engine calls the ArcGIS Server service