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?
<SPAN class="keyword token">string</SPAN> mmpkFilepath <SPAN class="operator token">=</SPAN> <SPAN class="string token">@"C:\temp\qtz_sample_land.mmpk"</SPAN><SPAN class="punctuation token">;</SPAN>
Console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"> Opening Map Package"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
Console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN>mmpkFilepath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Open the map package</SPAN>
MobileMapPackage myMapPackage <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> MobileMapPackage<SPAN class="punctuation token">.</SPAN><SPAN class="token function">OpenAsync</SPAN><SPAN class="punctuation token">(</SPAN>mmpkFilepath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Check that there is at least one map</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>myMapPackage<SPAN class="punctuation token">.</SPAN>Maps<SPAN class="punctuation token">.</SPAN>Count <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
Console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">" map package has maps"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Open the map package as a local service</SPAN>
<SPAN class="comment token">// Create a local feature service from a map package on disk</SPAN>
LocalMapService mapService <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">LocalMapService</SPAN><SPAN class="punctuation token">(</SPAN>mmpkFilepath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
Console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"> trying to start service"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">await</SPAN> mapService<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// this is where I'd do other stuff, but it fails</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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