ThinkGeo.com    |     Documentation    |     Premium Support

WmsTiledLayer - Exception

MapSuite Team,

I’m incorporating a WmsTiledLayer and receive the following exceptions when the WMS server is not available.

Is there a way to prevent an exception from occurring?

I’ve incorporated the DrawnException and DrawingException events, but they are not fired.

The client is V10.1.

Thanks,
Dennis

An unhandled exception of type ‘System.Net.WebException’ occurred in ThinkGeo.MapSuite.Wpf.dll

Additional information: Unable to connect to the remote server

An unhandled exception of type ‘System.ArgumentNullException’ occurred in ThinkGeo.MapSuite.Wpf.dll

Additional information: Value cannot be null.

Hi Dennis,

It looks your first exception is “Unable to connect to the remote server” which means your machine cannot connect to remote wms server, and because it return empty tile image, so maybe make the 2nd exception been thrown.

So I think you can try to make sure something as below:

  1. You can connect to wms server
  2. The parameters is correct you set for this layer, you can get the sending request and make sure the request can get correct tile image, and you can read the capability of the server to make sure whether you are using the correct parameters.

If you finally cannot make that works, maybe you can upload a simple sample and we can try to help you make it shows map.

Wish that’s helpful.

Regards,

Ethan

hi Ethan,

I believe this to be more than just doing a GetCapabilities. For example, When I am in debug mode in the WMS Server, with a breakpoint set, and then issue a WMS request from the client resulting in the breakpoint being hit. After short amount of time the WpfDesktopEdition client will encounter an exception.

I’m able to display a WMS Layer which contains three ShapeFileFeatureLayer on the client. It’s not that I cannot display the layers it is that when the WMS server is not available, or becomes unavailable, the client encounters exceptions.

I would think the client WMS layers should be robust enough to handle situations where the server is not available, without causing exceptions.

Your thoughts?

Thanks,
Dennis

Hi Dennis,

In fact you can set this property: layer.DrawingExceptionMode = DrawingExceptionMode.DrawException;

Which can just draw the exception instead of throw it.

And if you still cannot make your wms layer works, you can upload a simple sample here, we can help you look into it to see what’s the problem.

Regards,

Ethan

Ethan,

Previously I had set the DrawnException & DrawingException events and they are never fired. I did as you suggested and set DrawingExceptionMode to DrawException and still receive the same exception as shown below. I really can’t see this being a problem in my application because as long as the WMS server is available the layer displays just fine. It is only when the WMS Server is not available that the exceptions occur.

Is there some property that should be set such that if the server is not responding the WMS layer on the client behaves without an exception?

I would think that you could do a simple test and start one of your applications that makes use of a WMS layer and do not have your WMS server running and you should see the same exception. Now in order to properly test this your WMS server and WMS client must be separate applications. They cannot be combined as in your sample project.

My application only has one layer which is a WMS layer.

You suggested that I incorporate GetCapabilities in the client. I added code to invoke Open followed by GetServerCapabilitiesXml. The WmsHandler at the server sees the GetCapabilities request in ProcessRequestCore and issues a base.ProcessRequestCore(context);. However, the client side merely sees an empty string as the response. The server does have a capabilities document defined. How does the server return the capabilities?

Thanks,
Dennis

Ethan,

Here’s another exception being encountered. I set a breakpoint in the WMS Server that gets hit when the client issues an Open on a layer. If I stay in the debugger for something like 5 minutes then the exception below is encountered at the client.

Your thoughts?

Thanks,
Dennis

Hi Dennis,

Attached is a sample for TiledWMS layer, it works well in my machine, could you please try to run it and let me know whether it still met this exception?

And you can modify it to reproduce this exception, so we can make sure whether that’s the code reason or environment reason.

8732.zip (9.9 KB)

Regards,

Ethan

hi Ethan,

I downloaded your sample application and did a rebuild so it is using V10.02. When I enter debug mode the below exception occurs. This is one I’ve not seen before.

I’ve recently downloaded the ThinkGeo sample DisplayWmsRasterLayerSample-ForWinForms-master, which has almost identical code as 8732.zip, and it works just fine.

Here is the result of pinging the site…
ping ahocevar.com

Pinging ahocevar.com [104.27.163.149] with 32 bytes of data:
Reply from 104.27.163.149: bytes=32 time=30ms TTL=56
Reply from 104.27.163.149: bytes=32 time=32ms TTL=56
Reply from 104.27.163.149: bytes=32 time=30ms TTL=56
Reply from 104.27.163.149: bytes=32 time=31ms TTL=56

Ethan - I just went into Debug Mode again and it worked.

Dennis

Hi Dennis,

So it looks that works now?

Your exception information shows that’s a network problem, so I think that’s why the 2nd time you run it succeed.

Any question please let me know.

Regards,

Ethan

Ethan,

I upgraded from MapSuite V10.01 to V10.02 and this problem is partially solved.

The Layer Open method now results in an exception when the server is not available with the message – “Unable to connect to the remote server”. Under V10.01 this exception did not get passed back to the application and so the whole application crashed.

However, there is still an exception that is occurring inside of MapSuite. I start the WMS Server, I start the WMS Client, I display a layer in the client. Then I stop the WMS Server. At the client pan/zoom and MapSuite will crash as shown in the screen capture below.

Do you understand what I am talking about now? As long as the server is available my application has no issue. But as soon as the server is stopped the client will crash inside of MapSuite.

Does this make sense?

Just because the server was once available, but no longer available, MapSuite in the client should not crash, but gracefully handle this condition.

Dennis

Hi Dennis,

Thanks for you reply, I understand where is the problem now.

Our developer will look into it and see whether we can find a solution.

Regards,

Ethan

Hi Dennis,

Our developer had double check that, if you set the DrawingException property in overlay level that should works without crash.

Please view our sample here: 8732.zip (9.5 KB)

Wish that’s helpful.

Regards,

Ethan

Ethan,

I downloaded the sample and updated the NuGet packages and I do see the that map contains the pink tiles with X’s.

However, this is not my issue. I’m not sure you understand the issue I’m faced with.

As I stated in my previous post…“However, there is still an exception that is occurring inside of MapSuite. I start the WMS Server, I start the WMS Client, I display a layer in the client. Then I stop the WMS Server. At the client pan/zoom and MapSuite will crash as shown in the screen capture below.”

Does what I’m saying make sense to you?

Thanks,
Dennis

Hi Dennis,

Thanks for your reply, our developer will look into it, any update I will let you know.

Regards,

Ethan

Hi Dennis,

Our developer had fixed this problem, the exception reason will be drawn on tile.

Please update the 3 packages:



You can find the packages in one days.

And if you want to draw the exception information on tile, we suggest you set the DrawingException mode in overlay level, because the layer level cannot catch all exceptions for example the exception when you tried to open the layer.

Regards,

Ethan

hi Ethan,

I’ve updated with all the latest from MapSuite and implemented a timer that is enabled in the SendingWebRequest event and disabled in SentWebRequest. If the timer expires (I have it set to 5 seconds) the timer is disabled and a set of WmsRasterLayer.IsVisible = false is performed. In this case ThinkGeo.MapSuite.Wpf.dll appears to catch the exception and return it to WmsRasterLayer.Open, which then returns it to my application. This is all good.

However, there seems to be a timeout of about 120 seconds before WmsRasterLayer.Open returns with the exception.

Due to the environment that my product operates in, emergency communication centers, my users cannot afford to wait that long. I would like to programmatically change the wait time. Does MapSuite provide a method to change this wait time?

Well, I’ve just been doing more testing and I may have spoken too soon. In some cases I still get the exception inside MapSuite.

I’ve also been seeing that sometimes loading two layers from nearmap works and sometimes I get a timeout error/exception. I was consistently getting timeout exceptions in MapSuite attempting to load two layers from nearmap, states OHIO & PA. At least 5 times in a row I get the timeout. I then closed the Visual Studio solution, closed Visual Studio and restarted and then I could load OHIO & PA the very first time. Is MapSuite keeping data around that should be cleared or disposed?

After more testing after this update I’m getting more unusual things happening. Now the phrase " 29 DAYS LEFT" appears on my map. This must have something to do with license. How does one address this issue. I am on my development machine and my WpfDesktopEdition license is activated?

Also, I’ve been seeing on occasion instead of seeing the imagery I see just a plain white background.

Thanks,
Dennis

Hi Dennis,

Thanks for your description, it looks you met so many problems in your application. I listed the question here:

  1. If WMS server don’t reply, how to reduce the waiting time, the old value should be 120 seconds.

  2. Sometimes you met timeout error.

  3. You met eval exception sometimes.

  4. You met white blackground sometimes.

If I misunderstand please let me know.

For 1: Please try to set the Timeout for webrequest in the SendingWebRequest, it looks our wmsoverlay don’t contains related property.

For 2: I think that’s because your special format, you sent request to custom server, then sent another request to remote server, so sometimes the first request abort but the 2nd request still block the channel. I think only cache can help to reduce this problem.

For 3&4: Please try to add exception log in your server side code, so if you met the problem you can get the exception message and try to find what’s the reason of it.

Regards,

Ethan

hi Ethan,

Yes, I did encounter a lot of problems all of a sudden.

These issues are when my client application goes directly to nearmap.

Items #2 & #4 – I found what was causing the two US States of OHIO & PA not to load and to encounter timeout errors. I was setting the CurrentExtent of the MapControl to the ExpandedExtent of these two layers. I changed the code to not set CurrentExtent as shown below and now the two layers always appear.

Why do you think setting CurrentExtent caused this?

Old Code:

        TheAssetsStatic.aMapDisplay.CurrentExtent = TheBoundingBox;
        ThePointShape = TheBoundingBox.GetCenterPoint();
        TheMapDisplay.CenterAt(ThePointShape);
        TheMapDisplay.ZoomTo(ThePointShape, TheMapDisplay.ZoomLevelSet.ZoomLevel18.Scale);
        TheMapDisplay.Refresh();

New Code:

        ThePointShape = TheBoundingBox.GetCenterPoint();
        TheMapDisplay.CenterAt(ThePointShape);
        TheMapDisplay.ZoomTo(ThePointShape, TheMapDisplay.ZoomLevelSet.ZoomLevel18.Scale);
        TheMapDisplay.Refresh();

Item #3 – I am seeing “27 days left” while running in Visual Studio Debug Mode. When the exe is opened outside the debugger I do not see the eval notice. I updated to the latest MapSuite DLL’s including the latest Beta Version of MapSuite Barebones. How do I resolve the eval notice? What is the difference between Barebones & Standard?

Item #1 – I set WmsRasterLayer.TimeoutInSecond from the default of 20 to 5. Now 5 is a short time. But what it has shown is that when loading both OHIO & PA part of the image was returned and displayed, then my timer expired and so I sent WmsRasterLayer.IsVisible = false. As soon as that property was set received the following exception:

System.Net.WebException was unhandled
Message: An unhandled exception of type ‘System.Net.WebException’ occurred in ThinkGeo.MapSuite.Wpf.dll

Additional information: The request was aborted: The request was canceled.

Your thoughts?

Thanks,
Dennis

Hi Dennis,

  1. The CurrentExtent property contains complex calculate, generally it will works better, but you found set centerat and zoomto is works better for your scenario, please just keep that.

  2. About “27 days left”, please make sure all products you used is latest version and had been activated in your machine, and all cache had been cleared. The Barbone version only contains simplest packages, you can add the other ones you need, the standard contains all the packages, many of them is unused in common, we suggest you choose Barbone package.

  3. I don’t understand this question clearly, I guess you means after 5 seconds you set WmsRasterLayer.IsVisible = false but it thrown exception. Do you want to use this way to abort the sent request when timeout? Why not set the timeout in request directly?

Regards,

Ethan

hi Ethan,

About Item #2 – I now have 23 days left. This has something to do with MapSuite for WinForms because I opened the V10 Product Center and it also shows 23 days left for MapSuite WinForms. All my applications are WPF so somehow MapSuite WinForms has gotten into this MapSuite WPF application.

I’ve checked all my ThinkGeo packages for my application and they are WPF.

So somehow MapSuite for WinForms is caught up in my application.

What else can I check to determine where this is?

I do recall downloading one of your applications and it was a WinForms applications and I compiled it and it installed a eval copy for WinForms, which I would never have done if I knew it was going to install an eval copy. Is this where my trouble is? Can I uninstall MapSuite for WinForms?

Thanks,
Dennis