Select to view content in your preferred language

FeatureLayer.LoadAsync() results in an NullReferenceException

1511
3
Jump to solution
04-12-2018 06:42 AM
MaximilianGlas
Esri Contributor

Hi,

I have a strange behaviour in my two test applications, both based on ArcGIS Runtime 100.2.

Both worked fine for many hours of developing, now I got an exception in both, even I did not change anything in one of these apps.

Both a very small and focused and have the same startup:

        public MainWindow()
        {
            InitializeComponent();

            InitializeMap();
        }

        private async void InitializeMap()
        {
            Map map = new Map(Basemap.CreateTopographicVector());
            FeatureLayer featureLayer = new FeatureLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/2"));

            await featureLayer.LoadAsync();
            map.OperationalLayers.Add(featureLayer);

            MyMapView.Map = map;
        }

Both are now crashing in the same line 13, where the LoadAsync should be executed.

System.Net.Http.HttpRequestException occurred
  HResult=0x80131500
  Message=An error occurred while sending the request.
  Source=mscorlib
  StackTrace:
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Esri.ArcGISRuntime.Internal.RequestRequiredHandler.<IssueRequestAndRespond>d__15.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at CustomGPSProvider.MainWindow.<InitializeMap>d__1.MoveNext() in C:\Users\mag\Documents\Visual Studio 2017\Projects\CustomGPSProvider\CustomGPSProvider\MainWindow.xaml.cs:line 37

Inner Exception 1:
WebException: The request was aborted: The request was canceled.

Inner Exception 2:
NullReferenceException: Object reference not set to an instance of an object.

The StackTrace for the Inner Exception 2 is:

   at System.Net.HttpWebRequest.CheckCacheUpdateOnResponse()
   at System.Net.HttpWebRequest.CheckResubmitForCache(Exception& e)
   at System.Net.HttpWebRequest.DoSubmitRequestProcessing(Exception& exception)
   at System.Net.HttpWebRequest.ProcessResponse()
   at System.Net.HttpWebRequest.SetResponse(CoreResponseData coreResponseData)

I have no idea what's wrong.

Any ideas?

Max

0 Kudos
1 Solution

Accepted Solutions
MaximilianGlas
Esri Contributor

Thanks for your answer, but the problem still occured.

But I found a reason for the problem: I had Fiddler running in the background, logging the REST calls. That was the trigger for the occuring problem - if I close Fiddler, everything works as expected.

I was searching in the web for the reason of this problem as I do not expect such interaction, and I found that issue from Morten Nielsen (he seems to be everywhere ) which exactly describes my problem.

It seems that there is a problem in the .NET Runtime Core and as far as I can see, this problem will be solved in nearer future.

View solution in original post

3 Replies
NagmaYasmin
Esri Contributor

Hi,

Using your code, I am able to see the feature layer without any error. May be the time you were trying to access, the service was down, just a thought.

Were you able to access the service from the REST End point.

Featurelayer LoadAsync

0 Kudos
MaximilianGlas
Esri Contributor

Thanks for your answer, but the problem still occured.

But I found a reason for the problem: I had Fiddler running in the background, logging the REST calls. That was the trigger for the occuring problem - if I close Fiddler, everything works as expected.

I was searching in the web for the reason of this problem as I do not expect such interaction, and I found that issue from Morten Nielsen (he seems to be everywhere ) which exactly describes my problem.

It seems that there is a problem in the .NET Runtime Core and as far as I can see, this problem will be solved in nearer future.

dotMorten_esri
Esri Notable Contributor

I'm glad you figured it out, and glad I logged that issue a while back so that we have a fix very soon :-). You'll probably have to target the latest .NET Framework version, once that ships (it was only fixed about a week ago)

0 Kudos