ThinkGeo.com    |     Documentation    |     Premium Support

InvalidOperationException

Hi,


I am having an issue while zooming.


I am attempting to do the following:


I have various features that intersect. I need find a particular intersection point and zoom to the minumum scale with that point in the center of the map. Finding the point works fine but zooming randomly crashes.


Here is my code:


WinformsMap1.CenterAt(SelectedintersectionFeature.IntersectionPoint.Points(0))



WinformsMap1.CurrentScale = WinformsMap1.MinimumScale


WinformsMap1.Refresh()


This works most of the time but sometimes randomly this crashes with an InvalidOperationException. I havent been able to recreate this consistently even for the same exact point I want to zoom to.  I have also tried zoomtoscale method which also randomly crashes.


The full error below:


System.InvalidOperationException was unhandled

  Message="The Layer must be opened before you can perform this method."

  Source="MapSuiteCore"

  StackTrace:

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

       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.runTryCode(Object userData)

       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)

       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, 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)

  InnerException:


Can someone please help me with this.


Thank you


Madduri


 


 



 



Hi, We did some further testing and found that we were not able to recreate this issue on Windows XP SP2 32 bit. The problem seems to only occur in windows vista 32bit. We do not have immediate access to the 64bit versions of both XP and vista so I cannot say if the problem will or will not occur on the 64bit versions. We are using .net framework 3.5.  
  
 Thank you 
 Madduri

Madduri,


Thanks for your post and information.
 
I am just curious what the value of your MinmumScale in your application? And what is the unit of your application, it is in DecimalDegrees or Meter?
 
And if possible could you provide use a small sample to recreate your problem, probably it is very hard:) because you mentioned that it is very randomly.
 
Any more questions please feel free to let me know.
 
Thanks.
 
Yale

Hi Yale, 
  
 Thanks for your response. The minimum scale in the application is 200. The unit is meter. We are using Desktop Edition 3.0.307.0 
  
 I am not sure how I can provide s sample that reliably recreates this issue, However I did have a breakthrough in potentially pinpointing the issue. I changed the map from being multithreded to singlethreaded and since then we have not seen the issue. The performance of the application has taken a slight hit but I think it is still acceptable.  
  
 If you do have a patch or a fix for this issue please let me know. Would upgrading to a newer version of the desktop edition help? 
  
 Please let me know if you need any further information.  
  
 Thank you 
 Madduri

Madduri, 
  
 3.0.307.0 is a very old version and I remember it had some thread related issues. Could you please download the latest one 3.0.426? I think most possibly, this issue has been fixed in that version.  
  
 Thanks, 
  
 Ben

Hi Ben, 
  
 I downloded the 3.0.426 version and replaced the references in my application. I am now facing extremly show map refresh issues. Is there any special requirement to perform the upgrade? 
  
 Thanks 
 Madduri

Hi Madduri,


To upgrade to 3.0.426 from 3.0.307, you need to reference the new DLLs and recompile your application, because some APIs are obsolete and have been removed. For example, the property “TemporaryCacheDirectory” which is used in the constructor of old map control has been removed, so you can not run your application by changing the references only, you need to change the code of your application. There are many changes between these two versions, and I think you can get some detail information from this post:
gis.thinkgeo.com/Support/Dis...fault.aspx
Also, if you don’t want to upgrade your application, I suggest you not to close the layer until your application exits, because the default thread mode is multi-threading in 3.0.307, other thread may access a layer which has been closed by another thread and this will raise the InvalidOperationException.
Any more questions please let me know.
Thanks,
sun