I have written my own MapTileSource class that enables the xamMap to use a WMS. This works excellent and gives us access to all map sources we need.
However, now and then the WMS may fail on a single request for a tile and return an empty response. When this happens I receive the following exception:
System.AccessViolationException was unhandled Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. InnerException:
The result of the exception is that my Silverlight application crashes and terminates.
Since no stack trace or other information is available I am at a loss how to proceed. From what I have managed to figure out it seems that the xamMap control fails when the response for a tile request is empty. My GetTileLayers method fills the tileImageLayerSources list with the appropriate urls, but have no means of validating the request before it is performed. The urls are well formed, but as said the WMS sometimes fails on a single request.
Do yoy have any suggestions on how to handle this problem? If I somehow could trap the exception, hence avoiding the application crash, everything would be fine.
I have spent the day working on this problem, and have some new information. I have intercepted all requests and responses with the WMS server, as well as set up my own test site to return various reponses to test the behaviour of the xamMap.
I was wrong in that the WMS returns an empty response; it returns an error message as xml markup, like this one:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?><ServiceExceptionReport version="1.1.0"><ServiceException>[99][Interceptor]Overforbruk p� kort tid.Vent litt, pr�v igjen.(5)</ServiceException></ServiceExceptionReport>
This is not an error in the request, since trying it again in a few seconds return a valid tile. The error response from the WMS states that it is temporarily out of resources, and "please try again in a while".
However the end result stays the same; when this response arrives then the xamMap gets into trouble handling it. Since all this happens asynchrounously I have no place to attach an error handler (that I know of). Is it possible to attach an event handler of some sort to the xamMap in order to trap and handle this kind of errors?
Hi,
No, I do not make the actual WMS request manually. I have however tested some of the generated urls and verified that they are correct and return the expected images. The map also draws fine almost everytime. The problem is that the WMS server sometimes - I don't know why, maybe due to load - returns empty responses for valid requests.
The posted exception is all I get, there is no inner exception or other additional data. I also do not know where to attach an error handler to trap this error. If I could do that I would be good. Just handle the error and optionally try to refresh the map since the next time the request will work.
I'm only guessing when I suggest that it is the xamMap that runs into problems with the empty responses. However, since I do not have anything more to do with the WMS requests after building the urls, this is my only guess for now.
Hi Mikael,
After the GetTileLayers method fills your list of urls, are you then making the WMS requests manually then waiting for the response? Are you able to view the response after making the request and checking it to make sure it's valid?
I see that the InnerException portion of the error is missing in your post. Does the InnerException have any additional information?
I'm currently looking into this issue and I will have an update for you by tomorrow.