Hi, I have a pretty uncertain error when asking for UserInfo from IServerEnvironment from EnvironmentManager class.
System.InvalidCastException: Unable to cast object of type 'System.__ComObject' to type 'ESRI.ArcGIS.esriSystem.EnvironmentManagerClass'.
EnvironmentManager environmentManager = new EnvironmentManager();
UID environmentUid = new UID { Value = "{32d4c328-e473-4615-922c-63c108f55e60}" };
var environment = (IServerEnvironment3)environmentManager.GetEnvironment(environmentUid);
It fails at the first line.
My environment is Server 10.6.1 with Portal and Windows credentials SSO from our domain.
Sometimes it works, most of the time it fails. I'm pretty desperate, I hate these uncertain COM errors.