ThinkGeo.com    |     Documentation    |     Premium Support

RotationProjection shared between layers - exception

I have a RotationProjection object that is shared among multiple layers.  After moving to the .304 beta I'm getting exceptions complaining about the projection not being open...


Also, the map seems to come up with the 'Unlicensed' background a significant amount of time before my shapefiles are displayed...changed from the previous beta.


System.InvalidOperationException was unhandled

  Message="The projection is not open.  Please open it before calling this method."

  Source="MapSuiteCore"

  StackTrace:

       at ThinkGeo.MapSuite.Core.x6d719af406ea4c2c.xed94929c048fbff7(Boolean x40fc51452dedaf8a)

       at ThinkGeo.MapSuite.Core.Projection.ConvertToExternalProjection(Feature feature)

       at ThinkGeo.MapSuite.Core.FeatureSource.ConvertToExternalProjection(IEnumerable`1 features)

       at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawing(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable`1 returningColumnNames)

       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.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)

       at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)

       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x5e1f8125aa040824(Object x2680f14bfcc5c488)

       at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)

       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

 


 


I also had to put an Open/Close around the projection in my MouseMove event handler because I was getting a similar exception:




bool open = false;
if (!m_projection.IsOpen) 

    m_projection.Open(); 
    open = true; 

feature = m_projection.ConvertToExternalProjection(feature); 

if (open) 
{
    m_projection.Close(); 




This also happens with the second RC (307).


 



David, 
  
 I am afraid it’s hard to tell you whether this is a multi-thread issues or not without your code. But you can try to use the single thread mode to see whether this exception exists.  
 winformsMap1.ThreadingMode = MapThreadingMode.SingleThreaded; 
  
 If this exception only exists in the multi-thread mode, could you send us the code you are using to help you figure out what’s going on. 
 Meanwhile I propouse you to watch the video which talked about the changes and enhancements in RC1 as we didi lots of changes in this version. 
  
 Thanks, 
 ThinkGeo Support

This happened occasionally and seems to be a timing issue that comes and goes.  I’ve converted to the Enter/ExitWriteLock code and went to single threading (mostly because my dynamic layers were appearing when the map came up and the shapefile layers didn’t appear for multiple seconds after).  When/if it happens again, I’ll send you what I can and I’ll try to narrow it down.  Basically I have some shapefile layers other layers (approximately 10) all using the same projection.  The problem usually appeared right away when the app was coming up or if I resized the app.   
 I would think it seems to lean toward a threading issue on the draw whereever the projection is open/closed internally that is inot  checking whether the layer itself opened the projection before closing it. 
  
 Thanks, 
 Dave


 Dave, 
  
 Thanks for reporting! As we are using multi-threading in the latest version, it’s possible to have some threading related issues. But still we couldn’t recreate your problem: we tried 4 layers sharing the same projection and they are working fine. Just wondering did you lock your overlays in your code? Could you provide your codes which is very helpful for us to recreate the problem? 
  
 Thanks, 
  
 Ben 


I'll try this again, think I messed up my last post attempt.


I no longer have the exception when the map is drawing.  I think it was poor useage/understanding of the Enter/ExitWriteLock.  I also am now SingleThreaded.


WAS still getting an exception occasionally when I handle the MouseMove event (especially when dragging a feature).  It was complaining about the projection not being open on the following:


    feature = m_projection.ConvertToExternalProjection(feature);


Why would it be closed?  I don't do any Open/Close of the projection other than to handle this exception by doing the open myself.  This problem seemed to go away with my changes for post gis.thinkgeo.com/Support/Dis....aspx#8748 although I don't know why.


I don't know why it went away but I'll run with my workaroundcode the do the open commented out to see if it shows up again.  In short, at the moment things seem to work but my confidence level in this locking code ain't too high.


I'll attach my current code but for now the original problems on this post seem to be resolved.



Dave, 
  
 Thanks for your sharing codes. It looks a huge one):~~. 
  
 The Enter/Exit lock is a solution to solve the problems between threading, the projection Open/Closed problem is probably raised by threading. Because a projection project is shared in multiple threading, and when we draw, we will try to open—draw—close it. 
  
 Any all, any problems just let me know. 
  
 Thanks. 
 Yale.