[Mapguide-trac] [mapguide-trac] #2398: Duplicate key exception thrown when using Maestro IMappingService.CreateMap

MapGuide Open Source trac_mapguide at osgeo.org
Thu Jan 23 09:14:38 PST 2014


#2398: Duplicate key exception thrown when using       Maestro
IMappingService.CreateMap
----------------------------+-----------------------------------------------
   Reporter:  johngalambos  |       Owner:  jng  
       Type:  defect        |      Status:  new  
   Priority:  low           |   Milestone:       
  Component:  Maestro       |     Version:  2.5.0
   Severity:  minor         |    Keywords:       
External_id:                |  
----------------------------+-----------------------------------------------
 I'm coming across an issue when creating a RuntimeMap within Maestro.

 When using the IMappingService.CreateMap(runTimeMapId, mapDefinition,
 metersPerUnit) method, I am getting the following exception:


 {{{
 System.ArgumentException was unhandled
   HResult=-2147024809
   Message=An item with the same key has already been added.
   Source=mscorlib
   StackTrace:
        at System.ThrowHelper.ThrowArgumentException(ExceptionResource
 resource)
        at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue
 value, Boolean add)
        at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue
 value)
        at
 OSGeo.MapGuide.MaestroAPI.Http.Commands.HttpGetResourceContents.PutCompleted(IResource
 res) in c:\working\JenkinsCI\home\slave_win\jobs\Maestro
 5.0.x\workspace\OSGeo.MapGuide.MaestroAPI.Http\Commands\HttpGetResourceContents.cs:line
 51
        at
 OSGeo.MapGuide.MaestroAPI.Http.Commands.HttpGetResourceContents.<>c__DisplayClass4.<Execute>b__1(Object
 obj) in c:\working\JenkinsCI\home\slave_win\jobs\Maestro
 5.0.x\workspace\OSGeo.MapGuide.MaestroAPI.Http\Commands\HttpGetResourceContents.cs:line
 77
        at
 System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object
 state)
        at System.Threading.ExecutionContext.RunInternal(ExecutionContext
 executionContext, ContextCallback callback, Object state, Boolean
 preserveSyncCtx)
        at System.Threading.ExecutionContext.Run(ExecutionContext
 executionContext, ContextCallback callback, Object state, Boolean
 preserveSyncCtx)
        at
 System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
        at System.Threading.ThreadPoolWorkQueue.Dispatch()
        at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
   InnerException:
 }}}



 Stepping through the code, it appears that this is happening because the
 same layer is referenced twice within the map definition (although with a
 different display name and within a different group).

 In the OSGeo.MapGuide.MaestroAPI.Mapping.RunTimeMap class, there is a call
 to

 {{{
    _getRes.Execute(GetLayerIds(mdf)).
 }}}


 That call yields all the layer.ResourceIds without checking if there are
 duplicate resourceIds. The duplicates result in the exception when running
 the

 {{{
 OSGeo.MapGuide.MaestroAPI.Http.Commands.HttpGetResourceContent.Execute
 }}}

 method which fetches the resource contents of that layer twice and tries
 to add it to the _completed dictionary twice with the layer.ResourceId as
 the key.

 I'm currently using the Maestro 5.0 branch but I've looked and this code
 doesn't appear to be updated within the 5.1 branch. I am also connecting
 to a MGE 2011 server.

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/2398>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list