ThinkGeo.com    |     Documentation    |     Premium Support

WorldMapKitRenderLayer System.InvalidOperationException

 



Guys, sometimes DrawCore in WorldMapKitRenderLayer class throws System.InvalidOperationException when starting to draw dynamic layers.
 
Exception details is"  The GeoCanvas is currently not drawing.  Please call BeginDraw method before calling this method.   This is happening in the following snippet, immediately after the call to layer.Draw():
 
 
 

foreach (WorldMapKitShapeFileFeatureLayer layer in dynamicLayers)
            {
                if (candidateLayerNames.Count == 0 || candidateLayerNames.ContainsKey(Path.GetFileName(layer.ShapePathFileName)))
                {
                    canvas.BeginDrawing(image, extent, unit);
                    layer.Open();                    
                    layer.Draw(canvas, labelsInAllLayers);
                    layer.Close();
                    canvas.EndDrawing();
                }
            }


Klaus, 
  
 It seems like the canvas is closed when calling “Layer.Draw()”, but obviously, we initialized the canvas using “canvas.BeginDrawing”. Is there any multi-thread used in your application? Also I tested with WorldMapKit, but it works fine. Can you detail the problem, such as how you use the WorldMapKitLayer etc. 
  
 Thanks, 
 Johnny  



The full exception is posted below:


 


   at ThinkGeo.MapSuite.Core.x6d719af406ea4c2c.xbc32d22242378f5c(Boolean x1c27a8ea53684488)


   at ThinkGeo.MapSuite.Core.FeatureLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)


   at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)


   at ThinkGeo.MapSuite.Core.WorldMapKitRenderLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers) in C:\dev\LUT600 2.1.1\OCC600\Source\GIS\Modules\ThinkGeo\ThinkGeoLibrary\Layer\WorldMapKitRenderLayer.cs:line 2830


   at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)


   at ThinkGeo.MapSuite.WpfDesktopEdition.LayerTile.DrawCore(GeoCanvas geoCanvas)


   at ThinkGeo.MapSuite.WpfDesktopEdition.Tile.DrawPartial(GeoCanvas geoCanvas)


   at ThinkGeo.MapSuite.WpfDesktopEdition.Tile.Draw(GeoCanvas geoCanvas)


 



 Yes, application is multi-threaded but I doubt this is the problem.  If I disable the other processes that use background threads, problem still exists.


I am not doing anything fancy but attempting to load WorldMapKitLayer data off another pc on the network.  Despite the exception being thrown, the map still eventually draws but this is causing some excitement as it takes forever to load from another PC on a different domain.  Which leads to another question:


What is the recommended procedure for deploying WMK data for shared access?  Also, are there any special considerations to be made if this data is to be accessed from a PC on another domain?


 


 


 



 


Hi, Klaus
 
Thanks for your information about this problem. We have found where this exception throws from. But I don’t know why it occurs and I can’t recreate your problem. Have you tried the DLL package for the version of 4.0.40.0, or just try to render only one shape file?
 
If you had deployed the WMK data in another machine, and you need to give full permission to anyone that need to access it or just “everyone” group.
 
If problem still exists, also you can send us the codes you are using in the WpfDesktop client.
 
Thanks,
 
Khalil

Good to know you found the problem.   Where do I get the updated WorldMapKitRenderLayer class?  I do not think you distribute it with the core WPFDesktop package. 
  
 In terms of deployment, yes have granted read permission to the folder containing WMK data but it takes an unacceptable amount of time for the WorldMapKitRenderLayer to display each tile.

 


Hi, Klaus
Yes, we don’t distribute it with the WpfDesktop package, because it’s another product for WorldMapKit. If you want to get the latest version for WorldMapKit, please contact with the ThinkGeo sales.
In the last reply of mine, I mean I have found where the exception throws but I still don’t know why it occurs. I guess it’s related with multiple threads in WpfDesktop edition.
Have you tired the other samples for WorldMapKitRenderLayer? Such as DesktopEditionSample, WebEditionSample etc. Are they work as expected?
I look forward to your feedback.
Thanks,
Khalil

Hi Klaus, 
  
 Judging from your exception info, we guess you are using a LayerOverlay to be the container of the WorldMapKitRenderLayer, right?  
 If that’s the case, then we’d suggest you to use single tile mode by setting the TileType of LayerOverlay to SingleTile. 
  
 This may not be the best approach, we’ll keep digging deeper and we’ll let you know when we’ve got a better solution. 
  
 Regards, 
 Tsui

Hi Klaus, 
  
 The WorldMapKitRenderLayer is designed for single thread at the very beginning. The issue you have is caused by multi-thread. I tried to make some change on the layer’s DrawCore method; here are two places needs to be changed. First of all, go to DrawCore method of WorldMapKitRenderLayer; 
 1, commend out all the code of canvas.BeginDrawing(). 
 2, replace all code canvas.EndDrawing to canvas.Flush(). 
  
 After these two changes; my World map kit with local files work fine. 
  
 Please have a try and let me know if you have more queries. 
  
 Thanks, 
 Howard

 Howard, the suggested fix does not get rid of the exception.  Instead the situation appears to be slightly worse than before.   Unless you are using a different version of WMK.



Tsui, you are correct.  i am using a LayerOverlay with TileType set to multiple.   Please investigate the issue with MultipleTile when using WMK as soon as possible as MultipleTile is the preferred mode of operation.  SingleTile mode seems to be more deterministic though.   The tile is always drawn although the user experience is not as good as MultipleTile mode.  On the otherhand, in MultipleTile mode, I get all kinds of uncertainties. Either way, it appears i am stuck between a rock and hard place till you guys come up with a fix.  


Klaus


 


 


 


 



Hi Klaus, 
  
 I’m not sure if you have received our video about the running WMK on our end. It works fine and we don’t see any exception happens. I just think if it’s the data caused this issue. Please feed back. If possible, could you send us a file structure list to make sure that you are using the latest data? 
  
 Sorry for the inconvenience. 
  
 Thanks, 
 Howard