I have to send a message to the view model in PCL to log an exception when I catch unhandled exception in Appdelegate. I am not
able to send messages to the view model.. Running into compilation errors
Here is code in the AppDelegate for IOS :
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
Forms.Init();
}
private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
{
var exception = new Exception("TaskSchedulerOnUnobservedTaskException", unobservedTaskExceptionEventArgs.Exception);
// sending the message
MessagingCenter.Send( ExceptionLoggerViewModel, MessagingCenterMessages.ExceptionLoggerActivated, unobservedTaskExceptionEventArgs.Exception);
}
Here is the code in PCL in the view model where I subscribe for the message:
public ExceptionLoggerViewModel(ICache cache)
{
_cache = cache;
MessagingCenter.Subscribe<ExceptionLoggerViewModel, Exception>(this, MessagingCenterMessages.ExceptionLoggerActivated,
async (sender, exception) => await ExceptionLoggerViewModel_logException(exception));
}
I get an compilation error :
Error 13 'RA.Mobile.HEROGov.PCL.ViewModels.Pages.ExceptionLoggerViewModel' is a 'type' but is used like a 'variable' C:\tfs\VIRTUALRA8271L.REL.RA.Mobile.HEROGov\iOS\AppDelegate.cs 96 35 RA.Mobile.HEROGov.iOS
Any help is appreciated. Thanks