I'm trying to make an app in xamarin forms with EventAggregator and Prism. Till now I have made 3 Event, 2 of them work without problem, the last crash the app bun I don't understand why.
The event is this:
public class AggiuntaRigaOrdineEvent : PubSubEvent<RigaOrdine>
{
}
RigaOrdine is the model Class. To publish the event I use:
_ea.GetEvent<AggiuntaRigaOrdineEvent>().Publish(Riga);
where
RigaOrdine Riga = new RigaOrdine();
As you can se in the picture taked just before the crash the Riga variabile is full:
So why it give me error:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
EDIT: @Haukinger
The Excepion is thrown on the publish line, The stack call show:
0xAA in MokaDroid.ViewModels.NuovoArticoloOrdineClienteViewModel.<get_AggiungiRigaOrdine<get_AggiungiRigaOrdine>b__50_0>d at C:\Users\canap\source\repos\MokaDroid\MokaDroid\MokaDroid\ViewModels\NuovoArticoloOrdineClienteViewModel.cs:193,25 C#
The Subscriber is:
ea.GetEvent<AggiuntaRigaOrdineEvent>().Subscribe(RigaRicevuta);
Also if the app never arrive there. And the _ea is initialize in the constructor:
public NuovoArticoloOrdineClienteViewModel(IPageDialogService DialogSerices, INavigationService navigationService, IEventAggregator ea)
{
_DialogSerices = DialogSerices;
_navigationService = navigationService;
_ea = ea;
}
with IEventAggregator _ea; on the variable initialization on the begin of the viewmodel class.
What I don't understand, is that I have used the same way oter 2 times and it have work like a charm, here not.... and the 'Riga' variable is not NULL as you can see from the picture.
Here you have a list of all the variable and none are null...
_ea
actually set to something that's notnull
? – HaukingerNuovoArticoloOrdineClienteViewModel.cs
at line 193, I guess you'll have to do the debugging yourself. – Haukingernull
and why? – Haukinger