1、Arcengine调用GP服务,抛出异常方法
object sev = null;
try
{
Application.DoEvents();
gp.Execute(gpBuildPyramidsandStatistics, null);
Application.DoEvents();
Console.WriteLine(gp.GetMessages(ref sev));
}
catch (Exception ex)
{
// Print geoprocessing execution error messages.
MessageBox.Show(gp.GetMessages(ref sev));
}
//ps:调用GP服务处理数据库中的数据,必须添加gp的环境变量workspace.http://www.ithao123.cn/content-7464230.html
//Geoprocessor GP = new Geoprocessor();
//string sWorkPath;
//IWorkspace pWork;
//if(pWork.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
//{
//sWorkPath = System.IO.Path.Combine(Application.StartupPath,"gpenvwk.sde");
//pWork.WorkspaceFactory.Create(Application.StartupPath,"gpenvwk.sde",pWork.ConnectionProperties,0);
//}
//else
//{
//sWorkPath = pWork.PathName;
//}
//GP.SetEnvironmentValue("workspace",sWorkPath);
//GP.OverwriteOutput = true;