Estoy migrando algunos de ArcObjects código C# 10.1 y estoy teniendo algunos problemas a través de programación de la publicación de un MSD. Estamos usando un multi-configuración del sitio (no estoy seguro si lo que importa). Aquí es el código que estoy utilizando para publicar. He añadido algunos comentarios para ayudar a aclarar.
IAGSServerConnectionFactory3 pConnectionFactory = new AGSServerConnectionFactoryClass();
//admin connection file works fine, tested in ArcCatalog on the same server
IAGSServerConnection4 server = pConnectionFactory.OpenFromFile(@"e:\admin-connection.ags", 0) as IAGSServerConnection4;
IAGSServerConnectionAdmin pAGSServerConnectionAdmin = server as IAGSServerConnectionAdmin;
IServerObjectAdmin pServerObjectAdmin = pAGSServerConnectionAdmin.ServerObjectAdmin;
IServerObjectConfiguration4 pConfiguration = (IServerObjectConfiguration4)pServerObjectAdmin.CreateConfiguration();
//Set the general configuration settings
pConfiguration.Name = "output_56";
pConfiguration.TypeName = "MapServer";
pConfiguration.Description = "Map Output"; // required field in 10.1? Read that somewhere and added
pConfiguration.IsPooled = true;
pConfiguration.MinInstances = 1;
pConfiguration.MaxInstances = 15;
pConfiguration.WaitTimeout = 60;
pConfiguration.UsageTimeout = 600;
pConfiguration.IdleTimeout = 1800;
pConfiguration.StartupType = esriStartupType.esriSTAutomatic;
pConfiguration.IsolationLevel = esriServerIsolationLevel.esriServerIsolationAny;
//Set the configuration properties of the MapServer
IPropertySet pProps = pConfiguration.Properties;
//I have confirmed that the MSD exists and the FilePath is correct
pProps.SetProperty("FilePath", mapDocument);
//output directory is at network path on primary server on site \\10.7.1.XX\arcgisserver\directories\arcgisoutput\UserSims
// it should be noted that an empty directory is created here before the program crashes
pProps.SetProperty("OutputDir", outputDir);
//serverHost = "localhost", which is a secondary ArcServer on the site
// I commented this out because it looks like the arcgisoutput directory does not exist anymore.
// I'm not sure if this is required to publish, since we set OutputDir
//pProps.SetProperty("VirtualOutputDir", "http://" + serverHost + "/arcgisoutput");
pProps.SetProperty("MaxImageHeight", "2048");
pProps.SetProperty("MaxRecordCount", "1000");
pProps.SetProperty("MaxBufferCount", "100");
pProps.SetProperty("MaxImageWidth", "2048");
pConfiguration.Properties = pProps;
//Set the info segment properties
IPropertySet info = pConfiguration.Info;
info.SetProperty("WebEnabled", "true");
info.SetProperty("WebCapabilities", "Map,Query,Data");
pConfiguration.Info = info;
//Set the recycle properties of the MapServer object
IPropertySet recycle = pConfiguration.RecycleProperties;
recycle.SetProperty("StartTime", "1:00 AM");
recycle.SetProperty("Interval", "86400");
pConfiguration.RecycleProperties = recycle;
//Add the configuration to the server
pServerObjectAdmin.AddConfiguration(pConfiguration); //crashes here
pServerObjectAdmin.StartConfiguration(service, "MapServer");
Aquí es el error que estoy consiguiendo.
Unhandled Exception: System.Runtime.InteropServices.COMException (0x80040208): E
RROR: service failed to start, Cannot connect to this server.
at ESRI.ArcGIS.Server.IServerObjectAdmin.AddConfiguration(IServerObjectConfig
uration config)
at Matric.Modsim.SimulationCruncher.Publish.AddMapService(Geoprocessor gp, IA
GSServerConnection4 server, String serverHost, String outputDir, String service,
String mapDocument) in C:\Users\matt.moyles\Documents\Visual Studio 2010\Projec
ts\simulation2\simulation\Publish.cs:line 111
El error no tiene sentido para mí, porque me han confirmado el archivo de conexión es válida.
Si alguien podría aportar cualquier idea o sugerencia estaría muy agradecido!
EDITAR:
También he encontrado esta entrada en el arcgisserver registros:
<Msg time="2012-06-20T15:13:27,824" type="SEVERE" code="8274" source="Server" process="632" thread="1" methodName="" machine="ROGER-WATERS.TECH.LOCAL" user="" elapsed="">Failed to construct instance of service 'UserSims/output_56.MapServer'. </Msg>