System.Transactions Critical: 0 : <TraceRecord xmlns="schemas.microsoft.com/2004/1...raceRecord" Severity="Critical"><TraceIdentifier>msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>VSUClientApplication.vshost.exe</AppDomain><Exception><ExceptionType>System.InvalidOperationException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Collection was modified; enumeration operation may not execute.</Message><StackTrace> at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at ThinkGeo.MapSuite.Core.ZoomLevel.DrawCore(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)
at ThinkGeo.MapSuite.Core.ZoomLevel.Draw(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)
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.DrawOverlaysForMultiThread(Object drawingOverlaysObject)
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)</StackTrace><ExceptionString>System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at ThinkGeo.MapSuite.Core.ZoomLevel.DrawCore(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)
at ThinkGeo.MapSuite.Core.ZoomLevel.Draw(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)
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.DrawOverlaysForMultiThread(Object drawingOverlaysObject)
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)</ExceptionString></Exception></TraceRecord>
When having an layer with no projection, map.unit in meters, and 14.400 points in an layer, the are grided 1km x 1km
zoom in and remove points from layer, sometimes gives the exception above.
Build 3.0.411
Code for making overlay:
private LayerOverlay LoadPointLayer()
{
FeatureSourceColumn column = new FeatureSourceColumn("RepValue", "string", 101);
Collection<FeatureSourceColumn> columns = new Collection<FeatureSourceColumn>();
columns.Add(column);
InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer(columns, new Feature[] { });
pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay pointOverlay = new LayerOverlay();
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "RepValue";
valueStyle.IsActive = true;
for (int i = 0; i <= 100; i++)
{
Color color = repLayerSettingsControl.GetColorByPercent(i);
valueStyle.ValueItems.Add(new ValueItem(i.ToString(),
new PointStyle(PointSymbolType.Circle,
new GeoSolidBrush(GeoColor.FromArgb(color.A, color.R, color.G, color.B)), 5)));
}
pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
pointOverlay.Layers.Add("RepLayer", pointLayer);
return pointOverlay;
}
Code for remove:
winMap.Overlays["RepLayer"].Lock.EnterWriteLock();
try
{
InMemoryFeatureLayer pointLayer = (InMemoryFeatureLayer)winMap.FindFeatureLayer("RepLayer");
pointLayer.InternalFeatures.Clear();
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "RepValue";
valueStyle.IsActive = true;
for (int i = 0; i <= 100; i++)
{
Color color = repLayerSettingsControl.GetColorByPercent(i);
valueStyle.ValueItems.Add(new ValueItem(i.ToString(),
new PointStyle(PointSymbolType.Circle,
new GeoSolidBrush(GeoColor.FromArgb(color.A, color.R, color.G, color.B)), 5)));
}
pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();
pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
}
finally
{
winMap.Overlays["RepLayer"].Lock.ExitWriteLock();
}