ArcGIS Server Object Extension (SOE) from 10.3.1 to 10.6.1.

476
3
Jump to solution
12-17-2019 12:24 PM
WarrenMazoue
New Contributor

We are upgrading ArcGIS Server Object Extension (SOE) from 10.3.1 to 10.6.1. and I'd like to confirm a few things

We have a C# project that currently references - ESRI.ArcGIS.System  (we use two return types, IPropertySet and IServerEnvironment2) is this reference replaced by Esri System Object Library 10.6 (ESRI.ArcGIS.esriSystem;)?

[Update]

I am getting an error here

private THandlerInterface FindRequestHandlerDelegate<THandlerInterface>() where THandlerInterface : class
{
   try
   {
      IPropertySet props = ServerEnvironment.Properties;

   }

   catch (Exception e)
   {   
   }

}

private IServerEnvironment2 ServerEnvironment
{
get
   {
      if (_serverEnvironment == null)
      {
         UID uid = new UIDClass();
         uid.Value = "{32D4C328-E473-4615-922C-63C108F55E60}";

         // Create an EnvironmentManager and retrieve the IServerEnvironment
         IEnvironmentManager environmentManager = new EnvironmentManager() as IEnvironmentManager;
         _serverEnvironment = environmentManager.GetEnvironment(uid) as IServerEnvironment2;
      }

   return _serverEnvironment;
   }
}

[Error]

Instance of service ' AutomationException: Unable to cast object of type 'System.__ComObject' to type 'ESRI.ArcGIS.esriSystem.EnvironmentManagerClass'.

[/Error]

0 Kudos
1 Solution

Accepted Solutions
KirkKuykendall2
Occasional Contributor
3 Replies
KirkKuykendall2
Occasional Contributor

Did you try using Activator.CreateInstance instead of "new"?

How To: Get the current user name and roles using a server object extension 

WarrenMazoue
New Contributor

Thanks Kirk, that's pretty much what I needed to do.

I came across this other post 

https://community.esri.com/thread/226087-unable-to-cast-comobject-to-environmentmanager-in-soe 

which lead to a description of the bug here

BUG-000102447: The EnvironmentManager singleton object in the Serve.. 

0 Kudos
KirkKuykendall2
Occasional Contributor

It is my understanding that arcobjects singletons should always be instantiated via Activator.  This is a requirement of the "threads in isolation" design.

There may be singletons where using "new" works fine, but I've heard Activator should always work. (please someone chime in if this is not true)

0 Kudos