Select to view content in your preferred language

Starting map service in Local Server?

1448
3
Jump to solution
02-19-2019 10:06 AM
EricaPfister
Regular Contributor

I am trying to get Local Server working in a Runtime 100.4 .NET application. Mostly I need this for a geoprocessing service, but am trying to get it working with a map service first (just so I can verify I've got everything wired correctly).

I have an mmpk that I generated in Pro, and it has a few polygons. If I just load it in (using MobileMapPackage.OpenAsync) it shows up on a basemap, so it seems to have the data I expect. However, I cannot get it to work with Local Server as a map service.

I have confirmed that the LocalServer instance is started up (based on Console.WriteLine outputs in the code of its status, and opening it up in a browser while my application is running.) However, the following code is resulting in an error.

Is the problem with my LocalServer, my map package, some step of setting up a map service that I'm missing, or something else?

string mmpkFilepath = @"C:\temp\qtz_sample_land.mmpk";

Console.WriteLine("> Opening Map Package");
Console.WriteLine(mmpkFilepath);
// Open the map package
MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(mmpkFilepath);
// Check that there is at least one map
if (myMapPackage.Maps.Count > 0)
{
    Console.WriteLine(" map package has maps");
    // Open the map package as a local service
    // Create a local feature service from a map package on disk
    LocalMapService mapService = new LocalMapService(mmpkFilepath);
    Console.WriteLine("> trying to start service");
    await mapService.StartAsync();
    // this is where I'd do other stuff, but it fails
}

Esri.ArcGISRuntime.Http.ArcGISWebException
  HResult=0x80131500
  Message=Failed to create service qtz_sample_land MapServer. Service failed to initialize: IObjectConstruct::Construct (MapServer) hr=0x80043000 (ErrorInfo did not include a description)
  Source=Esri.ArcGISRuntime.LocalServices
  StackTrace:
   at Esri.ArcGISRuntime.LocalServices.LocalService.<StartServiceInternal>d__25.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at ESSQuartz_TracingGPK.MapViewModel.<StartServices>d__5.MoveNext() in C:\git\tester\ESSQuartz_TracingGPK\ESSQuartz_TracingGPK\MapViewModel.cs:line 111

0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor

Hi,

The Local Server component is not required for .mmpk files (Mobile Map Package) - you can open those directly in the API. Local Server is only required for ArcGIS Pro Map Packages which have the file extension .mpkx.

For more info see Local Server—ArcGIS Runtime SDK for .NET | ArcGIS for Developers 

Cheers

Mike

View solution in original post

3 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

The Local Server component is not required for .mmpk files (Mobile Map Package) - you can open those directly in the API. Local Server is only required for ArcGIS Pro Map Packages which have the file extension .mpkx.

For more info see Local Server—ArcGIS Runtime SDK for .NET | ArcGIS for Developers 

Cheers

Mike

EricaPfister
Regular Contributor

Thank you for your answer. One clarification -- LocalServer "not required for mmpk" and "will not work with mmpk" are slightly different... can I assume that using an mmpk to test my LocalServer instance is never going to work and I should just generate an mpkx instead?

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Yes, that's correct: Local Server only works with Pro .mpkx / .gpkx files or ArcMap .mpk / .gpk files.

I recommend using .mmpk files for you mapping content and only using local server for your geoprocessing via .gpkx files.

Cheers