<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OnlineRouteTask throws an exception 'System.ArgumentNullException: A value can not be null. Parameternavn: source' in SolveAsync  in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/onlineroutetask-throws-an-exception-system/m-p/452861#M5535</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have problem when I use the Online Rote tak to find the shortest driving distance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The OnlineRouteTask class throws an exception &lt;EM&gt;'System.ArgumentNullException: A value can not be null'&lt;/EM&gt; in the function 'SolveAsync'. I have tried to set/change all the parameters in the call with no luck.&lt;/P&gt;&lt;P&gt;It used to work, so I am a little puzzled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is my code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;async Task&amp;lt;double&amp;gt; FindDistance(double fromLat, double fromLon, double toLat, double toLon)&lt;BR /&gt; {&lt;BR /&gt; double distance = -1;&lt;BR /&gt; try&lt;BR /&gt; {&lt;BR /&gt;&lt;SPAN&gt; const string RouteUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Froute.arcgis.com%2Farcgis%2Frest%2Fservices%2FWorld%2FRoute%2FNAServer%2FRoute_World" rel="nofollow" target="_blank"&gt;http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;var fromPoint = new MapPoint(fromLon, fromLat, SpatialReferences.Wgs84);&lt;BR /&gt; var fromSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.X, Size = 10, Color = Colors.Green };&lt;BR /&gt; var fromMapGraphic = new Graphic { Geometry = fromPoint, Symbol = fromSym };&lt;/P&gt;&lt;P&gt;var toPoint = new MapPoint(toLon, toLat, SpatialReferences.Wgs84);&lt;BR /&gt; var toSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.X, Size = 10, Color = Colors.GreenYellow };&lt;BR /&gt; var toMapGraphic = new Graphic { Geometry = toPoint, Symbol = toSym };&lt;/P&gt;&lt;P&gt;var routeTask = new OnlineRouteTask(new Uri(RouteUrl));&lt;BR /&gt; var routeParams = await routeTask.GetDefaultParametersAsync();&lt;BR /&gt; //routeParams.OutSpatialReference = ihmMapView.SpatialReference;&lt;BR /&gt; //routeParams.DirectionsLengthUnit = LinearUnits.Kilometers;&lt;BR /&gt; routeParams.ReturnDirections = false;&lt;BR /&gt; routeParams.OutputLines = OutputLine.None;&lt;BR /&gt; //routeParams.ReturnPointBarriers = true;&lt;BR /&gt; //routeParams.FindBestSequence = true;&lt;BR /&gt; var restrictions = new List&amp;lt;string&amp;gt;();&lt;BR /&gt; restrictions.Add("Avoid Ferries");&lt;BR /&gt; restrictions.Add("Driving an Emergency Vehicle");&lt;BR /&gt; routeParams.RestrictionAttributeNames = restrictions;&lt;/P&gt;&lt;P&gt;var stopGraphics = new List&amp;lt;Graphic&amp;gt;();&lt;BR /&gt; stopGraphics.Add(fromMapGraphic);&lt;BR /&gt; stopGraphics.Add(toMapGraphic);&lt;BR /&gt; routeParams.SetStops(stopGraphics);&lt;/P&gt;&lt;P&gt;var routeResult = await routeTask.SolveAsync(routeParams); &lt;STRONG&gt;&amp;lt;--- Exception is thrown here&lt;/STRONG&gt;&lt;BR /&gt; foreach (var de in routeResult.Routes[0].TotalCosts)&lt;BR /&gt; {&lt;BR /&gt; if (de.Key == "Kilometers")&lt;BR /&gt; {&lt;BR /&gt; distance = de.Value;&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; catch (Exception e)&lt;BR /&gt; {&lt;BR /&gt; log.Error(e);&lt;BR /&gt; }&lt;BR /&gt; return distance;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The&amp;nbsp;Exception:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ERROR - System.ArgumentNullException: A value can not be null.&lt;BR /&gt;Parameternavn: source&lt;BR /&gt; ved System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.NetworkDescription.GetTimeAndLengthAttributes(NAParameters parameters, String&amp;amp; timeAttribute, String&amp;amp; lengthAttribute)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.NAParameters.GetParameters(NetworkDescription networkDescription, Boolean autoNormalize)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.RouteParameters.GetParameters(NetworkDescription networkDescription, Boolean autoNormalize)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.OnlineRouteTask.&amp;lt;SolveRequest&amp;gt;d__17.MoveNext()&lt;BR /&gt;--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.OnlineRouteTask.&amp;lt;Solve&amp;gt;d__12.MoveNext()&lt;BR /&gt;--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)&lt;BR /&gt; ved InformiGis.IhmMapControl.&amp;lt;FindDistance&amp;gt;d__106.MoveNext()&lt;STRONG&gt; &amp;lt;--- This is my function&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Mar 2018 14:45:49 GMT</pubDate>
    <dc:creator>OleJuul2</dc:creator>
    <dc:date>2018-03-08T14:45:49Z</dc:date>
    <item>
      <title>OnlineRouteTask throws an exception 'System.ArgumentNullException: A value can not be null. Parameternavn: source' in SolveAsync</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/onlineroutetask-throws-an-exception-system/m-p/452861#M5535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have problem when I use the Online Rote tak to find the shortest driving distance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The OnlineRouteTask class throws an exception &lt;EM&gt;'System.ArgumentNullException: A value can not be null'&lt;/EM&gt; in the function 'SolveAsync'. I have tried to set/change all the parameters in the call with no luck.&lt;/P&gt;&lt;P&gt;It used to work, so I am a little puzzled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is my code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;async Task&amp;lt;double&amp;gt; FindDistance(double fromLat, double fromLon, double toLat, double toLon)&lt;BR /&gt; {&lt;BR /&gt; double distance = -1;&lt;BR /&gt; try&lt;BR /&gt; {&lt;BR /&gt;&lt;SPAN&gt; const string RouteUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Froute.arcgis.com%2Farcgis%2Frest%2Fservices%2FWorld%2FRoute%2FNAServer%2FRoute_World" rel="nofollow" target="_blank"&gt;http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;var fromPoint = new MapPoint(fromLon, fromLat, SpatialReferences.Wgs84);&lt;BR /&gt; var fromSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.X, Size = 10, Color = Colors.Green };&lt;BR /&gt; var fromMapGraphic = new Graphic { Geometry = fromPoint, Symbol = fromSym };&lt;/P&gt;&lt;P&gt;var toPoint = new MapPoint(toLon, toLat, SpatialReferences.Wgs84);&lt;BR /&gt; var toSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.X, Size = 10, Color = Colors.GreenYellow };&lt;BR /&gt; var toMapGraphic = new Graphic { Geometry = toPoint, Symbol = toSym };&lt;/P&gt;&lt;P&gt;var routeTask = new OnlineRouteTask(new Uri(RouteUrl));&lt;BR /&gt; var routeParams = await routeTask.GetDefaultParametersAsync();&lt;BR /&gt; //routeParams.OutSpatialReference = ihmMapView.SpatialReference;&lt;BR /&gt; //routeParams.DirectionsLengthUnit = LinearUnits.Kilometers;&lt;BR /&gt; routeParams.ReturnDirections = false;&lt;BR /&gt; routeParams.OutputLines = OutputLine.None;&lt;BR /&gt; //routeParams.ReturnPointBarriers = true;&lt;BR /&gt; //routeParams.FindBestSequence = true;&lt;BR /&gt; var restrictions = new List&amp;lt;string&amp;gt;();&lt;BR /&gt; restrictions.Add("Avoid Ferries");&lt;BR /&gt; restrictions.Add("Driving an Emergency Vehicle");&lt;BR /&gt; routeParams.RestrictionAttributeNames = restrictions;&lt;/P&gt;&lt;P&gt;var stopGraphics = new List&amp;lt;Graphic&amp;gt;();&lt;BR /&gt; stopGraphics.Add(fromMapGraphic);&lt;BR /&gt; stopGraphics.Add(toMapGraphic);&lt;BR /&gt; routeParams.SetStops(stopGraphics);&lt;/P&gt;&lt;P&gt;var routeResult = await routeTask.SolveAsync(routeParams); &lt;STRONG&gt;&amp;lt;--- Exception is thrown here&lt;/STRONG&gt;&lt;BR /&gt; foreach (var de in routeResult.Routes[0].TotalCosts)&lt;BR /&gt; {&lt;BR /&gt; if (de.Key == "Kilometers")&lt;BR /&gt; {&lt;BR /&gt; distance = de.Value;&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; catch (Exception e)&lt;BR /&gt; {&lt;BR /&gt; log.Error(e);&lt;BR /&gt; }&lt;BR /&gt; return distance;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The&amp;nbsp;Exception:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ERROR - System.ArgumentNullException: A value can not be null.&lt;BR /&gt;Parameternavn: source&lt;BR /&gt; ved System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.NetworkDescription.GetTimeAndLengthAttributes(NAParameters parameters, String&amp;amp; timeAttribute, String&amp;amp; lengthAttribute)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.NAParameters.GetParameters(NetworkDescription networkDescription, Boolean autoNormalize)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.RouteParameters.GetParameters(NetworkDescription networkDescription, Boolean autoNormalize)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.OnlineRouteTask.&amp;lt;SolveRequest&amp;gt;d__17.MoveNext()&lt;BR /&gt;--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt; ved Esri.ArcGISRuntime.Tasks.NetworkAnalyst.OnlineRouteTask.&amp;lt;Solve&amp;gt;d__12.MoveNext()&lt;BR /&gt;--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt; ved System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)&lt;BR /&gt; ved InformiGis.IhmMapControl.&amp;lt;FindDistance&amp;gt;d__106.MoveNext()&lt;STRONG&gt; &amp;lt;--- This is my function&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Mar 2018 14:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/onlineroutetask-throws-an-exception-system/m-p/452861#M5535</guid>
      <dc:creator>OleJuul2</dc:creator>
      <dc:date>2018-03-08T14:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: OnlineRouteTask throws an exception 'System.ArgumentNullException: A value can not be null. Parameternavn: source' in SolveAsync</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/onlineroutetask-throws-an-exception-system/m-p/452862#M5536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: transparent; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #3d3d3d; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; vertical-align: baseline; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;I believe you need an ArcGIS Online organizational account to use the world routing service. Are you using &lt;EM style="border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: italic; font-weight: 400; outline-color: invert; outline-style: none; outline-width: 0px; vertical-align: baseline; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;IdentityManager&lt;/EM&gt; to set credentials for the service? I tested with your code and valid credentials and I see routes and distances generated as expected.&lt;/P&gt;&lt;P style="background-color: transparent; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #3d3d3d; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; min-height: 10.66px; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; vertical-align: baseline; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: transparent; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #3d3d3d; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; vertical-align: baseline; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word; padding: 0px; margin: 0px; border: 0px none #3d3d3d;"&gt;The 10.2.7 guide for accessing a secure service is &lt;A href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fdevelopers.arcgis.com%2Fnet%2F10-2%2Fdesktop%2Fguide%2Fsecurity.htm" rel="nofollow" style="background-attachment: scroll; background-clip: border-box; background-color: transparent; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #287433; display: inline; fill: #287433; font-family: arial,helvetica,&amp;amp;quot; helvetica neue&amp;amp;quot;,verdana,sans-serif; font-size: 15px; font-style: normal; font-weight: 400; height: auto; outline-color: invert; outline-style: none; outline-width: 0px; text-decoration: none; transition-delay: 0s; transition-duration: 0.1s; transition-property: color; transition-timing-function: cubic-bezier(0, 0, 1, 1); vertical-align: baseline; width: auto; padding: 0px calc(0.35ex + 12px) 0px 0px; margin: 0px; border: 0px none #287433;" target="_blank"&gt;here.&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2018 18:06:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/onlineroutetask-throws-an-exception-system/m-p/452862#M5536</guid>
      <dc:creator>GregDeStigter</dc:creator>
      <dc:date>2018-03-09T18:06:37Z</dc:date>
    </item>
  </channel>
</rss>

