IGISServerConnection2 conn = new GISServerConnectionClass(); Conn.Connect(); Returns Class not registered error

2835
12
09-02-2020 04:47 AM
AmitabhaSarkar
New Contributor

I am executing following code from VS 2019 from a ServerObjectExtension and getting error gisConnection.Connect().

 

            IGISServerConnection2 conn = new GISServerConnectionClass(); //GISServerConnection()

            conn.Connect2("arcgis","NTPCSRV01"); --- Returns error

            conn.Connect( "NTPCSRV01"); -- Returns error

 

Error Message - System.Runtime.InteropServices.COMException HResult=0x80040154 Message=Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) Source=ESRI.Server.Server

 

Even if I referenced ESRI.ArcGIS.Server then also I receive similar error.

0 Kudos
12 Replies
by Anonymous User
Not applicable

IGISServerConnection is deprecated since 10.1. You should use IAGSServerConnection instead to connect to ArcGIS Server/Enterprise/Online services by its URL, like this code:

IPropertySet propertySet = new PropertySet();
propertySet.SetProperty("URL", "https://sampleserver6.arcgisonline.com/arcgis/services");
propertySet.SetProperty("USER", "user1"); //You may comment out this line if the service is not secured
propertySet.SetProperty("PASSWORD", "user1");//You may comment out this line if the service is not secured
IAGSServerConnectionFactory agsServerConnectionFactory = new AGSServerConnectionFactory();
IAGSServerConnection agsServerConnection = agsServerConnectionFactory.Open(propertySet, 0);
IAGSEnumServerObjectName agsSONames = agsServerConnection.ServerObjectNames;
agsSONames.Reset();
IAGSServerObjectName agsSOName = agsSONames.Next();
int i = 1;
while (agsSOName != null)
{
if (agsSOName.Type == "MapServer")
{
object pObj = ((IName)agsSOName).Open();
IMapServer pMapServer = pObj as IMapServer;
string description = pMapServer.GetServerInfo(pMapServer.DefaultMapName).Description;
Debug.WriteLine(i + " " + agsSOName.Name + " : " + description);
i++;
}
agsSOName = agsSONames.Next();
}

0 Kudos
AmitabhaSarkar
New Contributor

Thanks very much for your response. Tried similar approach but unable to get SOM and Server Context. Will try this and let you know my observation.

0 Kudos
by Anonymous User
Not applicable

ServerObjectManager and ServerContext are also deprecated since 10.1. You shouldn't use this approach to manage server objects or manage server. It's only possible to use ArcObjects to get server/service info (read or use the service), but not to manage/edit server or services.

If you want to manage services (start/stop/remove/publish), you can explore:

- Server admin REST API (Edit Service—ArcGIS REST API | ArcGIS for Developers)

- Publish services (Approaches to publishing services—ArcGIS Server | Documentation for ArcGIS Enterprise )

- Arcpy (Example: Publish various service types using service definitions—ArcGIS Server | Documentation for A...).

These approaches can be implemented or invoked in c# or Java too. 

0 Kudos
AmitabhaSarkar
New Contributor

Thanks Very much for the information. I am new to ESRI ArcObjects development. I am trying to migrate a SOE written on ArcGIS Server 10.0 t0 10.8.1. With this SOE, I just wanted to find out a layer, highlight the desired area and save that layer as a gif file. Could you please suggest how shall I proceed. Many thanks in advance.

0 Kudos
by Anonymous User
Not applicable

The function you mentioned should already be available with built-in map service Export Map (using dynamic layers) REST API (Export Map—ArcGIS REST API | ArcGIS for Developers ). This article Alternatives to server object extensions—ArcGIS Server | Documentation for ArcGIS Enterprise discusses the similar workflow as yours and recommends using dynamic layers. If this approach works for you, then you do not even have to develop your own SOE, but rather using the out-of-box functions provided with map service.

0 Kudos
AmitabhaSarkar
New Contributor

Hi Hanhan Sun,

Thanks very much for your response. Tried export map API but couldn’t able to export the map with coloring of selected region. Earlier we were using following JSON for exporting and printing a map.

Here I am generating the following JSON from .NET web application and pass it to a SOE which saves the generated image in output folder. I was trying to generate the same image with supplying following parameters: Bounding Box, Layer Definition, Bounding Box Spatial Reference, Image Type, DPI and trying to put values in dynamic layers with intention of filtering the value of intended location but always got “Error Parsing Dynamic Layers”.

Could you please help me in trying out how to retrieve the intended area from the map layers and color it for printing.

Many thanks in advance.

Regards,

Amitabha

{

"mapservice":"Dashboard",

"mapextent":{

"inital_extent":false,

"thematic_map":1,

"useBbox":false

},

"functions":{

"ZoomIn":true,

"ZoomOut":true,

"Pan":true,

"Home":true,

"Prev":true,

"Next":true,

"Identify":true,

"IdentifyHeatmap":true,

"XY":true,

"Print":true,

"Cluster":true,

"Legend":false,

"Selection":true,

"ChooseBasemap":true,

"BasemapOpacity":true,

"basemap":true

},

"layervisibility":[

{

"layerId":1,

"visible":false

},

{

"layerId":2,

"visible":true

},

{

"layerId":3,

"visible":false

},

{

"layerId":4,

"visible":false

},

{

"layerId":5,

"visible":false

},

{

"layerId":6,

"visible":false

},

{

"layerId":7,

"visible":false

},

{

"layerId":8,

"visible":false

},

{

"layerId":9,

"visible":false

},

{

"layerId":10,

"visible":false

},

{

"layerId":11,

"visible":false

},

{

"layerId":12,

"visible":false

},

{

"layerId":13,

"visible":false

},

{

"layerId":14,

"visible":false

},

{

"layerId":15,

"visible":false

},

{

"layerId":16,

"visible":false

},

{

"layerId":17,

"visible":false

},

{

"layerId":23,

"visible":false

}

],

"identifyoption":"all",

"printoptions":{

"title":" Male Population., Number, 2016, Municipality Araru, Municipality",

"subtitle":"",

"footprint":"Population Man., Number, 2016",

"printwidth":100,

"format":"jpg",

"type":"map",

"printsize":"A4",

"dpi":96,

"customsize":"in %",

"printheight":100,

"basemap":"https://localhost:6443/arcgis/services/Basemap_OSM/MapServer",

"basemaptransparency":0.3

},

"thematic_maps":[

{

"id":1,

"layerId":2,

"legendtitle":"Number",

"legenddetails":"",

"unit":"Number",

"symbol":{

"transparency":1,

"filltype":"SOLID",

"outline":{

"transparency":0.3,

"width":1,

"outlinetype":"SOLID",

"outlinecolor":[

0,

0,

0

]

}

},

"classbreakrenderer":[

{

"color":[

194,

201,

236

],

"min":0,

"max":426

},

{

"color":[

177,

184,

223

],

"min":426,

"max":964

},

{

"color":[

160,

168,

209

],

"min":964,

"max":1915

},

{

"color":[

143,

151,

196

],

"min":1915,

"max":7945

}

],

"values":[

{

"id":4001,

"value":7942,

"labeltext":"Araru\n7942"

}

]

}

],

"regions":{

"layerId":0,

"regioncode":"",

"layertext":""

},

"locale":"en"

}

0 Kudos
nicogis
MVP Frequent Contributor

see:

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//000100000p7w000000

'... At 10.1, you can no longer use ArcObjects remotely (via DCOM); this way of interacting with ArcGIS for Server is no longer supported. If you are using GISServerConnection in the Server library or AGSServerConnection in the GISClient library in your code, these need to be removed if you are working with ArcGIS 10.1 for Server...'

0 Kudos
AmitabhaSarkar
New Contributor

Thanks for the information. If  so then why it is exists in latest documentation as well. This is not clear.

https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#GISServerConnection.htm 

0 Kudos
nicogis
MVP Frequent Contributor

With GISServerConnection you can connect to arcgis server 10.0  (it's in help for connection dcom)

0 Kudos