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.
Of cource, my mistake. Too bit in a hurry. Anyway, here is the project.
Mikael
Hi Mikael,
The large file size may be from the bin and obj folders being included in the zip file. Deleting these folders should bring the file size down well below the posting limit.
Change of plans, so I found the time today to assemble a small test project. The sample application uses www2.demis.nl (a free sample wms) to draw a map of the world. The MapTileSource class included triggers an invalid wms request for every 20th map tile. Also every wms request and response are written to the Immediate window. When the initial map is completed just start zooming and you will see the error triggered.
As you can see when the wms returns a response not being a valid image then the whole application shuts down. I acknowledge that the map expects valid image tiles as responses, but it would be nice if it could have some sort of basic validation or error trapping, allowing the application to continue even when a tile fails from time to time.
I have zipped the wms test project resulting in a zip file of size 2MB. I am not allowed to upload this file due to its size, so if you please can provide an email address or other means to deliver the file.
Regards, Mikael
Hi, and thanks for following up.
I'm a bit short of time due to a project meeting tomorrow, but I'll put together a small test project later this week.
The XamMap deals strictly with image urls and does not process WMS in any way so it makes sense that the XamMap wouldn't know what to do if the url ended up returning XML instead of an image. I want to try and get a sample built that reproduces this issue. Is it possible for you to provide one that I can take a look at. If not can you provide the code your using to create the XamMap as well as the code for your custom MapTileSource? Also is the WMS server your using a public server that I will be able to request data from?