I got another exception which never happened in previous beta version. I have a PostgreFeatureLayer, when I call the QueryTools.GetFeaturesIntersecting() method, I got an "InvalidOperationException was unhandled" exception, the message is "The projection is not open. Please open it before calling this method".
We found this as well. It is a bug, we had code in the LayersOverlayDrawCore to close each layer after it drew and it is not supposed to. This created a bunch of open issues. We have corrected this and within a few hours we will have a new build posted.
We have also created an hour long video explaining the new features and how to use them. The video is done but still producing. I hope to have it online later today or tomorrow morning. We will add a sticky to the DesktopEdtion forum and also developer blog post when it is ready.
I got the same exceptoin in the new build 3.0.307.
If I have less data in my PostgreFeatureLayer, everything is fine, but if I have more data, I got the exception, my code has finished, and I am not doing anything, it seems MapSuite is doing sth at the background and throws this exception.
Still, we couldn’t recreate your problem under 32bit operating system. We will try it under 64bit later. Can you let me know the size of your data base, like how many records are there?
Just make sure in the single threading mode, can you reproduce this problem or not. If so, I think it is probably not a threading problem of Desktop Edition.
If you cannot reproduce this problem in Single threading mode, but can produce this problem in Multi-threading mode. I suggest you can provide us your codes to see if you lock all the places as required because in this version, we will need to Lock everyplace when we change the overlay just like the Video talked about.
I can not re-produce the problem in Single threading mode, and in Multi-Threading mode, only when I have lots of data in my postgreFeatureLayer I get this exception.BTW, my program is single-threaded.
Here is the code:
If CType(mnuBar.Items(VESSELRADIUSSEARCH_CMD_ID), ToolStripButton).Checked = True And Map1.TrackOverlay.TrackMode = TrackMode.Circle Then
Dim feature1 As Feature = Map1.TrackOverlay.TrackShapeLayer.InternalFeatures.Item(Map1.TrackOverlay.TrackShapeLayer.InternalFeatures.Count - 1) Map1.TrackOverlay.TrackShapeLayer.InternalFeatures.RemoveAt(Map1.TrackOverlay.TrackShapeLayer.InternalFeatures.Count - 1) Map1.TrackOverlay.Lock.IsDirty = True Dim selectedFeatures As Collection(Of Feature) Dim postgreLyr As FeatureLayer = Map1.FindFeatureLayer("VesselPointsLayer")
Map1.Refresh() If selectedFeatures.Count > 0 Then Me.DataGridView1.DataSource = MapEngine.LoadDataTable(selectedFeatures, vesselReturningColumns) UpdateInfoWindowForVessel() Else Me.DataGridView1.DataSource = Nothing End If End if
It was a hard time to create the “projection is closed” exception. I try to open and close the projection very quickly in a timer, and it will throw the “Projection is not open. Please open it before calling the method” exception when I call Refresh many times.
In our drawing logic in the Map.Refresh, we will use another threading to draw in which will use the projection. And seems in your sample codes you will open it and close it one time, I think this might cause the problem.
So I suggest you do not close the projection after getting the interesting features.
I am getting this error also. If I leave the map up for a little bit and don't do anything, but then go to pan the map or something, this is when this error pops up. I don't know what leaving the projection open does, but that seems to go against good programming practices. Why does it need to be open? I'll post the stack trace below. Do you think I'm missing a read lock on something? Since I just the error out of nowhere and it's not somewhere I can trace into, it's difficult to figure out the problem. This is one of those times when failing earlier would be helpful if I'm not doing something right.
Thanks,
Kimberly
" at ThinkGeo.MapSuite.Core.x6d719af406ea4c2c.xed94929c048fbff7(Boolean x40fc51452dedaf8a)\r\n at ThinkGeo.MapSuite.Core.Projection.ConvertToInternalProjection(RectangleShape rectangleShape)\r\n at ThinkGeo.MapSuite.Core.FeatureSource.ConvertToInternalProjection(RectangleShape rectangle)\r\n at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawing(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable`1 returningColumnNames)\r\n at ThinkGeo.MapSuite.Core.FeatureLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)\r\n at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)\r\n at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)\r\n at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)\r\n at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x5e1f8125aa040824(Object x2680f14bfcc5c488)\r\n at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)\r\n at System.Threading.ExecutionContext.runTryCode(Object userData)\r\n at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)\r\n at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)"
I will try my best to explain to you what is happening.
Basically, the codes will be as following paten when this error would possibly happen:
In the Form_Loaded event: layerOverlay.Add(dbLayer); winfourmsMap.Overlay.Add(layerOverlay);
Every time you want to refresh a Map: dbLayer.Open dbLayer.SpatialQuery dbLayer.Close()
winformsMap1.Refresh ();
You know, in the Map. Refresh, we will create another drawing threading when using multi-threaded mode. Suppose we refresh the map at random frequency. Refresh a Map First time Refresh a Map Second time …
When we refresh the Map first time, we will create another threading (let us say DrawThreading1) to draw the map, but when DrawThreading1 threading starts to draw the dbLayer, it will first Open the layer which connect to the db and then start to get data from db server, but just between the middle, the second refresh the Map close the dbLayer after doing the spatial query. Then this exception happened.
So, In general speaking, 2 solutions are suitable to solve this problem decently. 1) Use single threaded mode for the Map to refresh. 2) DONOT close the connection to the DB after your execute the Spatial Query.
I am not sure I am clear enough, if not, just feel free to let me know.