FormsMap.XMapUrl exceptions assigning the xMapServer URL

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.
Post Reply
pssdiogo
Posts: 16
Joined: Wed Oct 29, 2014 3:13 pm

FormsMap.XMapUrl exceptions assigning the xMapServer URL

Post by pssdiogo »

Hello Ptv Team

While debugging, the "Output Window" shows 2 exceptions when the property FormsMap.XMapUrl is assigned to the xMapServer URL. This is an internally handled exception that is only displayed in the output window, after which the form is loaded and the map shown correctly.

Environment Info:
I'm using the Ptv XServer.Net Version 1.7.8.0 and your C# sample code "FormsMapCS":
https://github.com/ptv-logistics/xserve ... FormsMapCS

1 Exception using your xMapServer URL:
formsMap1.XMapUrl = "https://xmap-eu-n-test.cloud.ptvgroup.com/xmap/ws/XMap";

Exception thrown: 'System.ObjectDisposedException' in System.dll
at System.Net.Sockets.NetworkStream.get_InternalSocket()
Cannot access a disposed object.


2 Exceptions using our xMapServer http url:
formsMap1.XMapUrl = "http://192.168.101.29:50010/xmap/ws/XMap";

Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
at System.Net.HttpWebRequest.GetResponse()
The remote server returned an error: (404) Not Found.


How can we remove both exception?

Thank you in advance for your support.
Kind regards
Pedro Diogo
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: FormsMap.XMapUrl exceptions assigning the xMapServer URL

Post by Bernd Welter »

Hello Pedro,

I forwarded this to Oli... Please stay tuned!

Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Oliver Heilig
Posts: 160
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: FormsMap.XMapUrl exceptions assigning the xMapServer URL

Post by Oliver Heilig »

Hello Pedro,

do i understand you right, your program is running, but you see exceptions in the console? I have debugged the the samples with "All Exceptions", and i think they come from the "intelligent" Uri-detection. This guesses the correct uri scheme and xserver version. I think this causes the 404s, but the "acess to disposed" object looks like a bug in the control.

I can take a look at it, but i generally advice to initialize the control explicity for productive environments, without the "smart detection". The sample CustomInit shows this practice. This will generally lead to faster startup times, and will also not raise internal exceptions.

Take a look at "CustomInit" here https://github.com/ptv-logistics/xserver.net-samples

Oli
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany

https://github.com/oliverheilig/
pssdiogo
Posts: 16
Joined: Wed Oct 29, 2014 3:13 pm

Re: FormsMap.XMapUrl exceptions assigning the xMapServer URL

Post by pssdiogo »

Hello Oliver

Thank you for your quick reply.
Perfect, it works exactly as you described it.
I have no more exceptions and it seems to be faster. Thank you.

However, I still have the same question regarding the xServer2 url.
The "CustomInit" sample it's only valid for xServer1, right?

I would like to start the migration of our maps to the xServer2.
Could you suggest me a sample code that I can follow to do it?
Thank you once again.

Best regards,
Pedro Diogo
pssdiogo
Posts: 16
Joined: Wed Oct 29, 2014 3:13 pm

Re: FormsMap.XMapUrl exceptions assigning the xMapServer URL

Post by pssdiogo »

Hello Oliver

Can you please help me with the initialization of the XMap2 using Feature Layers?

As explained below, I have followed two projects, the first focusing on feature layers and the second avoiding "smart" Uri detection in the FormsMap.XMapUrl property. But in both approaches, the initialization of the map Uri causes me problems.

1) I followed the FeatureLayer code-sample:
Xmap2LayerFactoryTest #xserver-2

Issue:
It works very well, but it crashes if the FormsMap control is initialized more than 3 times during the same application execution. It crashes when the URL is assigned in the FormsMap.XMapUrl property.
Xmap2LayerFactoryTestImg
Xmap2LayerFactoryTestImg
I have created a sample project to illustrate the problem.
Xmap2LayerFactoryTest.zip
Xmap2LayerFactoryTest
(3.04 MiB) Downloaded 606 times

2) To avoid FormsMaps "intelligent" Uri-detection, I then explicitly initialized the control following the "XSTwo" code-sample as described in the topic: https://xserver.ptvgroup.com/forum/view ... map2#p1350

Issue:
It works well and I can then open the map several times, but the problem is that then the FormsMap.Xmap2LayerFactory is not initialized.

Thank you in advance for your support.
Kind regards
Pedro Diogo
User avatar
Oliver Heilig
Posts: 160
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: FormsMap.XMapUrl exceptions assigning the xMapServer URL

Post by Oliver Heilig »

Hello Pedro,

this looks like the number of (ephermal) connections isn't enough. Adding a

ServicePointManager.DefaultConnectionLimit = 64;

at your application startup for example increases the default limit and fixes the timeout. I would generally recommend to specify the limit, the control itself doesn't make any changes there.

Oli
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany

https://github.com/oliverheilig/
pssdiogo
Posts: 16
Joined: Wed Oct 29, 2014 3:13 pm

Re: FormsMap.XMapUrl exceptions assigning the xMapServer URL

Post by pssdiogo »

Hello Oliver

Oh yes, you are absolutely right. It works perfectly now.
Thank you for your quick response.

Best regards,
Pedro Diogo
Post Reply