Uno.NullReferenceException: Object reference was null

Fuse used: Fuse 1.1.1 (build 13893).

I’m having a following error:

Uno.NullReferenceException: Object reference was null
   at Fuse.Navigation.Router.SetRouteImpl(Fuse.Visual,Fuse.Navigation.Route,Fuse.Navigation.NavigationGotoMode,Fuse.Navigation.RoutingOperation,string,Fuse.Navigation.IRouterOutlet&)
   at Fuse.Navigation.Router.SetRoute(Fuse.Navigation.Route,Fuse.Navigation.NavigationGotoMode,Fuse.Navigation.RoutingOperation,string,[bool])
   at Fuse.Navigation.Router.Modify(Fuse.Navigation.ModifyRouteHow,Fuse.Navigation.Route,Fuse.Navigation.NavigationGotoMode,string)
   at Fuse.Navigation.Router.Push(Fuse.Navigation.Route,[string])
   at Fuse.Navigation.Router.Push(Fuse.Scripting.Context,Fuse.Navigation.Router,object[])
   at Fuse.Scripting.ScriptMethod`1.CallClosure.Run()
   at Fuse.UpdateManager.ProcessPostActionsImpl()
   at Fuse.UpdateManager.ProcessPostActions()
   at Fuse.UpdateManager.Update()
   at Fuse.App.OnUpdate()
   at Outracks.Simulator.Client.Application.OnUpdate()
   at Fuse.App.OnTick(object,Uno.Platform.TimerEventArgs)
   at Uno.Platform.Display.OnTick(Uno.Platform.TimerEventArgs)
   at Uno.Platform.Displays.TickAll(Uno.Platform.TimerEventArgs)

while using this function for routing:

function showVisitForm() {
  console.log(JSON.stringify(company.value));
  router.push('new-visit-form', { company: company.value });
}

The console.log however for the company.value return the right object:

{"id":2572164,"name":"Test 241"}

This happens only on iOS device preview, the desktop Fuse Preview works as expected.

I’ve filed an issue about the null reference. Can you tell me more about when this happens? Does it always happens, or have you done some specific sequence of events.

  1. It’s happening always when adding the “company” object to reference in router push.
  2. This happens only on iOS device preview. The desktop preview passes the reference normally and displays the page correctly.
  3. When not adding the “company” object the page renders correctly, without proper data.
  4. I’ve also tried to add args to the function and just pass the args to reference, but this gives the same error.

Is the company object a simple object? The parameter in routing supports only things that are JSON serializable. You should be passing an ID to the company and not the company object itself.

It’s unclear how this would produce the given erorr, or that it wasn’t detected, but maybe that can at least unblock you.

This worked. Thought that I could do with one less fetch from API.
Though I don’t know why this worked on desktop preview.

In this model you’re expected to do some caching of your own in your JavaScript: having a store to load customers from.

You’ll be happy to know in an upcoming release (1.3 possibly) we have a different state model system that will allow you to add objects directly to the navigation path.

Great ! This will help a lot.