ThinkGeo.com    |     Documentation    |     Premium Support

Draw Exception vs Throw exception

I'm confused about something. I recently reworked how I was handling my layers. I have all my layers set to simply draw the exceptions. When I gave my coworker the new code, when he would turn on one of the sql server layers and it would draw the pink exception layer. I can never get this to happen on my machine.


I changed the code to throw the exception to see if I could figure out what causing his issue. I had a generic catch block already to handle the thrown exception and so the only code I changed was the one line that changed the overlay to throw the exception instead of draw it. I checked it in, he checked it out and now it works on his machine. No error is getting caught by my catch block and the layer (s) are all being drawn correctly. What was the exception that was causing it to draw pink? Why isn't that same exception being caught by my catch block?


Can you explain how this is possible? The sql layers are only referencing a view. sql group 'public' has select permission on all views. I'm referencing the exact same database and everything and we have all the same permissions to the database.


Any clues would be appreciated. I don't want to leave it set to throw the exceptions.


Thanks!


Kimberly



I have some added weirdness. The next time my coworker ran the map (this time, no code changes), he’s again getting the pink exception layer, but the catch block I have to catch the exception isn’t being reached. Nothing has changed in the database and now it just seems that some times it works and some times it doesn’t.

Kimberly, 
  
 In order to solve your problem and make the problem clear, could you provide a simple sample? That way we can go directly to resolving your problem instead of spending time setting up your scenario and trying to recreate the error on our side. If you don’t fell confortable sending your project in the Discussion Forum, you can use one of your Support tickets in the Customer Portal.  
  
 Thanks 
  
 James

James, as I said, I can’t recreate this issue easily. It only happens sometimes. Use the code that I uploaded yesterday here:  
 gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/7007/afv/topic/Default.aspx 
  
 The only difference is that I have a tree on my real form that lists the layers and allows them to turn on and off layers by checking check boxes. All the code does in that case is figure out what layer they want, figure out what overlay that is and then lock the overlay, set isVisible to On/Off and then in the finally block exit the write lock.  The layers that are causing this are sql2008 layers using views. The code that defines those layers is included in the sample I uploaded yesterday.  
  
 The method that defined the overlay that these layers are on adds the layers and then sets this: 
 FileBitmapTileCache bitmapTileCache = new FileBitmapTileCache(); 
  bitmapTileCache.CacheDirectory = @"C:\GISCache" + overlayName; 
  bitmapTileCache.CacheId = overlayName; 
  bitmapTileCache.ImageFormat = TileImageFormat.Png; 
  
  overlay.TileCache = bitmapTileCache; 
  overlay.TileCache.ClearCache(); 
  overlay.DrawingExceptionMode = DrawingExceptionMode.ThrowException;

I forgot to include this in the last message. My layers and my overlays are both set to throw the exceptions now. (I'm not sure that I had them both set the same before).


This morning my coworker has turned on some of the SQL2008 layers and had them work and then another time, he has the infamous "Projection is not open" exception happen. Could this be the exception that is sometimes causing them not to show? I thought that this issue was finally resolved quite a while back. I was rather surprised to see it again.


Here's the stack trace:


System.InvalidOperationException was unhandled
 Message="The projection is not open. Please open it before calling this method."
 Source="DesktopEdition"
 StackTrace:
       at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)
       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xef6cc4fa8fda72d7(RectangleShape xb35a33b423b17f65, Overlay x99251f66cdabc2ad, Int32 xa209325f5c895f7e, Int32 x7454a0d1965919b1, GeographyUnit xbb704b4400ce6f76)
       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xef6cc4fa8fda72d7(Object x9c95f4613bdc3113)
       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:

Kimberly,


Please look at another post that David have answered your question.


gis.thinkgeo.com/Support/Dis...fault.aspx


Thanks


James