Select to view content in your preferred language

How to load a map document from a network path?

5421
12
Jump to solution
10-29-2012 01:10 PM
Labels (1)
GeorgeFaraj
Frequent Contributor
I'm trying to load a map package, i.e load every layer contained in the map package (mpk file). This map package is in a shared network path. I've tried several ways of doing this, but I haven't found why this is failing.

This is all I get:

ESRI.ArcGIS.Client.Local.LocalServerException was unhandled   Message=Failed to create service clark MapServer. Service failed to initialize: IObjectConstruct::Construct (MapServer) hr=0x80043000 (ErrorInfo did not include a description) Error code: 500   Source=ESRI.ArcGIS.Client   StackTrace:        at ESRI.ArcGIS.Client.Layer.OnInitializationFailed(EventArgs e)        at ESRI.ArcGIS.Client.Layer.Initialize()        at ESRI.ArcGIS.Client.FeatureLayer.Initialize()        at ESRI.ArcGIS.Client.Local.ArcGISLocalFeatureLayer.FailInitialize(Exception error)        at ESRI.ArcGIS.Client.Local.ArcGISLocalFeatureLayer.CompleteServiceInitialize(LocalMapService mapService)        at ESRI.ArcGIS.Client.Local.LocalMapService.<>c__DisplayClass1.<GetServiceAsyncInternal>b__0(Object s, AsyncCompletedEventArgs e)        at ESRI.ArcGIS.Client.Local.LocalService.OnStartCompleted()        at ESRI.ArcGIS.Client.Local.LocalService.FailStart(Exception error)        at ESRI.ArcGIS.Client.Local.LocalService.<ContinueStartService>b__a(CreateServiceResponse createServiceResponse, RequestInfo createServiceInfo)        at ESRI.ArcGIS.Client.Local.Internal.Requests.ProcessResponse[TExpectedResponse](String url, String queryParameters, Exception err, Boolean cancelled, String result, Action`2 callback)        at ESRI.ArcGIS.Client.Local.Internal.Requests.<>c__DisplayClass7`1.<Start>b__2(Object s, UploadStringCompletedEventArgs e)        at System.Net.WebClient.OnUploadStringCompleted(UploadStringCompletedEventArgs e)        at System.Net.WebClient.UploadStringOperationCompleted(Object arg)        at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)        at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)        at System.Windows.Threading.DispatcherOperation.InvokeImpl()        at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)        at System.Threading.ExecutionContext.runTryCode(Object userData)        at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)        at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)        at System.Windows.Threading.DispatcherOperation.Invoke()        at System.Windows.Threading.Dispatcher.ProcessQueue()        at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)        at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)        at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)        at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)        at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)        at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)        at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)        at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)        at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)        at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)        at System.Windows.Application.RunDispatcher(Object ignore)        at System.Windows.Application.RunInternal(Window window)        at System.Windows.Application.Run(Window window)        at System.Windows.Application.Run()        at AdvancedRuntimeControls.App.Main() in C:\Users\gfaraj\Desktop\Source_Code\AdvancedRuntimeControls\obj\Debug\App.g.cs:line 0        at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)        at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()        at System.Threading.ThreadHelper.ThreadStart_Context(Object state)        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)        at System.Threading.ThreadHelper.ThreadStart()   InnerException: 




The code:

    
LocalMapService localMapService = new LocalMapService() {  Path = @"\\dtdev7240w7\Terminated\GIS Data\clark gis\clark.mxd",  MaxRecords = 100000 }; localMapService.StartAsync(localService => {  if (localService.Error != null)   return;  ArcGISLocalDynamicMapServiceLayer layer = new ArcGISLocalDynamicMapServiceLayer(localMapService);  MyMap.Layers.Add(layer); });



Other attempt:

MyMap.Layers.Add(new ArcGISLocalFeatureLayer(@"\\dtdev7240w7\Terminated\GIS Data\clark gis\clark.mxd", "Clark"));
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor
Hi,

You need to turn the Map Document (MXD) into a Map Package (MPK) - please see this doc for more information: http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/About_map_packages/017000000059....

The main decision to make when creating the MPK is whether to include the data where all data sources get pulled into a single .MPK file or to reference the data in it's original location where the MPK is just a very small file contaiing the rendering info and all the data remains in it's source location. You may want the latter.

Looks like we could provide a better error message in this scenario though - I'll investigate.

Cheers

Mike

View solution in original post

0 Kudos
12 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

You need to turn the Map Document (MXD) into a Map Package (MPK) - please see this doc for more information: http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/About_map_packages/017000000059....

The main decision to make when creating the MPK is whether to include the data where all data sources get pulled into a single .MPK file or to reference the data in it's original location where the MPK is just a very small file contaiing the rendering info and all the data remains in it's source location. You may want the latter.

Looks like we could provide a better error message in this scenario though - I'll investigate.

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Oh, I seem to have mixed up map documents and map packages. I exported my map to a MPK using ArcMap (is there a standalone utility that does this by the way?), but it's still failing with the same error message.

Just to make sure, we can't open MXD's using the Runtime SDK?

Thanks,
George
0 Kudos
GeorgeFaraj
Frequent Contributor
I tried this way:

MyMap.Layers.Add(new ArcGISLocalFeatureLayer(@"\\dtdev7240w7\Terminated\GIS Data\clark gis\clark.mpk", "parcels"));


and at least got a better error message:

Failed to create service clark2 MapServer. Service failed to initialize: The map package is not supported by the ArcGIS Runtime. There is no .msd file available inside the package. Check that it was authored with ArcGIS Runtime support enabled. Error code: 500


So where can I specify Runtime support? The help URL you gave me doesn't say where the Map Package dialog is accessed from.
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

When creating the package did you check the box for support ArcGIS Runtime? If you don't see this on the map packaging dialog then you'll need to enable the ArcGIS Runtime tools in the options > sharing dialog - more info here: http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/How_to_create_a_map_package/017....

To create a standalone utility you can use python and the Package Map GP tool but it will still need a desktop license.

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Yup, I tried now with ArcGIS Runtime support enabled, and I'm still getting the same error. I tried checking "Reference All" and unchecking it, and it's still giving me the same error.

When sharing the map package, I get the following messages in ArcMap. Could this be causing problems?

SEVERITY STATUS CODE DESCRIPTION NAME TYPE DATA FRAME
Medium Unresolved 10027 Layer's data source is referenced via a UNC path parcels Layer Layers
Low Unresolved 30003 Layer draws at all scale ranges parcels Layer Layers


Thanks,
George
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

UNC paths should work - i just retested a local MPK with layers referencing data via a UNC path and also the MPK itself via a UNC path and both worked fine.

If you're still getting the same error then you could try deleting the contents of Documents\ArcGIS\Packages - although it should unpack the MPK again if you've recreated it.

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Thanks Mike, I got it working, I had a mistake in the xaml.

One more question: can I only load layers through map packages? I use ESRI.ArcGIS.Controls.ControlsAddDataCommandClass in my ArcObjects Engine 10.1 app to show the "Add Data" dialog that allows the user to add several types of layers (.shp and .lyr for example). Is this still available in the Runtime?
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

Creating Map and Tile packages is the recommended approach. However, we're well aware that many folk still like to let users add Shapefiles, Geodatabase feature classes and rasters directly to a map and let them set the symbology. We are planning to improve our support for more adhoc data workflows in a future release but for now it's still relatively easy to add Shapefiles and Rasters. Geodatabase feature classes are fine too if you know the feature class names beforehand.

Take a look at this sample which demonstrates the process: http://www.arcgis.com/home/item.html?id=953a530ada30477d95cc69e788268bc9.

The API explanation can be found here: http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Cli....

Cheers

Mike
0 Kudos
GeorgeFaraj
Frequent Contributor
Thanks Mike, that worked well. I'm not quite where I want to be yet though. When I use this method to add a shapefile, it doesn't have a symbol attached to it. How can I set a default symbol when I add the shape? I get back a reference to ArcGISLocalDynamicMapServiceLayer, which doesn't have a Symbol property.
0 Kudos