I am facing similar problem using NET SDK. have created a gpk using the below python script in ArcGIS 10.3.When trying to consume as Local geoprocessing service in 10.2.6,I get below errors when running the application.I am not trying to Deploy yet.
What is the correct procedure to solve this ?
import arcpy
from arcpy import env
import os
env.workspace = arcpy.GetParameter(0)
fcList = arcpy.ListFeatureClasses()
text_file = open("C:/Output242.txt", "w")
for fc in fcList:
print fc.rstrip(".shp")
text_file.write(fc.rstrip(".shp"))
text_file.close()
I am using the below code in C# NET for consuming this gpk service.
private string gpkPath = @"C:\Script2.gpk";
private string gpUrl = string.Empty;
private async void StartLocalGpService()
{
var gpService = new LocalGeoprocessingService(gpkPath,GeoprocessingServiceType.Execute);
await gpService.StartAsync();//Fails Here
gpUrl = gpService.UrlGeoprocessingService;
var geoprocessor = new Geoprocessor(new Uri(gpUrl +"/Script2"));
}
Sorry for the confusion. Can you post this in the .NET space? ArcGIS Runtime SDK for .NET
That will notify the .NET community and they will be able to help investigate.
Thanks,
Luke
License your app—ArcGIS Runtime SDK for .NET | ArcGIS for Developers
The first error shouldn't stop you but not having a basic license is why you would get that error. See licensing sheet linked above.
One last thought. Is it possible that you did not enable runtime on your GPK? Can you upload your GPK for further inspection?
I think I can live with the first error.Tried below code after enabling runtime on GPK - still getting more errors.Please let me know how to upload the gpk file..
private static string gpkPath = @"C:\arcgis-runtime-samples-dotnet-master\samples-
data\geoprocessing\TableToExcel\TableToExcel.gpk";
private Geoprocessor _gpTask;
private async void StartButton_Click(object sender, RoutedEventArgs e)
{
try
{
var gpService = new LocalGeoprocessingService(gpkPath, GeoprocessingServiceType.Execute);
await gpService.StartAsync();
string gpUrl = gpService.UrlGeoprocessingService;
_gpTask = new Geoprocessor(new Uri(gpUrl + "/TableToExcel"));
GetServiceInfo();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Sample Error");
}
}
private async void GetServiceInfo()
{
string message = null;
try
{
var result = await _gpTask.GetTaskInfoAsync();
var sb = new StringBuilder();
if (result != null)
{
sb.Append("{");
sb.AppendLine(string.Format("\t\"name\" : \"{0}\",", result.Name));
sb.AppendLine(string.Format("\t\"displayName\" : \"{0}\",", result.DisplayName));
sb.AppendLine(string.Format("\t\"category\" : \"{0}\",", result.Category));
sb.AppendLine(string.Format("\t\"helpUrl\" : \"{0}\",", result.HelpUrl));
sb.AppendLine(string.Format("\t\"executionType\" : \"esriExecutionType{0}\",", result.ExecutionType));
sb.AppendLine("\t\"parameters\" : [");
foreach (var p in result.Parameters)
{
sb.AppendLine("\t{");
sb.AppendLine(string.Format("\t\t\"name\" : \"{0}\",", p.Name));
sb.AppendLine(string.Format("\t\t\"dataType\" : \"{0}\",", p.DataType));
sb.AppendLine(string.Format("\t\t\"displayName\" : \"{0}\",", p.DisplayName));
sb.AppendLine(string.Format("\t\t\"direction\" : \"esriGPParameterDirection{0}\",", p.Direction));
sb.AppendLine(string.Format("\t\t\"defaultValue\" : \"{0}\",", p.DefaultValue));
sb.AppendLine(string.Format("\t\t\"parameterType\" : \"esriGPParameterType{0}\",", p.ParameterType));
sb.AppendLine(string.Format("\t\t\"category\" : \"{0}\"", p.Category));
if (p.ChoiceList != null)
{
sb.AppendLine("\t\t\"choiceList\" : [");
foreach (var c in p.ChoiceList)
sb.AppendLine(string.Format("\t\t\t\"{0}\"", c));
sb.AppendLine("\t\t\"]");
}
sb.AppendLine("\t},");
}
sb.AppendLine("\t]");
sb.Append("}");
message = sb.ToString();
}
}
catch (Exception ex)
{
message = ex.Message;
}
MessageBox.Show(message, "Service Info");
}