title: Xamarin Forms MessagingCenter: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation
body: <p>Getting the below exception when trying to send a string value through <code>MessagingCenter</code>. The exception is on a <strong>PopupPage</strong>.</p>
  
  <p><strong>Exception Details:</strong></p>
  
  <blockquote>
    <p>exception:>>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
      at CatholicBrain.Views.BibleOrderGamePage.&lt;.ctor>b__3_0 (CatholicBrain.Model.BibleOrderGameViewModel s, System.String answer) [0x00001] in F:\My Projects\Xamarin\catholicbrain-mobile-app\CatholicBrain\CatholicBrain\Views\BibleOrderGamePage.xaml.cs:30 
      at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&amp;)
      at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in &lt;46c2fa109b574c7ea6739f9fe2350976>:0 
       --- End of inner exception stack trace ---
      at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00086] in &lt;46c2fa109b574c7ea6739f9fe2350976>:0 
      at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in &lt;46c2fa109b574c7ea6739f9fe2350976>:0 
      at Xamarin.Forms.MessagingCenter+Subscription.InvokeCallback (System.Object sender, System.Object args) [0x00064] in D:\a\1\s\Xamarin.Forms.Core\MessagingCenter.cs:94 
      at Xamarin.Forms.MessagingCenter.InnerSend (System.String message, System.Type senderType, System.Type argType, System.Object sender, System.Object args) [0x0006b] in D:\a\1\s\Xamarin.Forms.Core\MessagingCenter.cs:217 
      at Xamarin.Forms.MessagingCenter.Xamarin.Forms.IMessagingCenter.Send[TSender,TArgs] (TSender sender, System.String message, TArgs args) [0x00013] in D:\a\1\s\Xamarin.Forms.Core\MessagingCenter.cs:115 
      at Xamarin.Forms.MessagingCenter.Send[TSender,TArgs] (TSender sender, System.String message, TArgs args) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\MessagingCenter.cs:108 
      at CatholicBrain.Model.BibleOrderGameViewModel.StartBibleOrderCheck (CatholicBrain.Model.BibleOrderAnswer selectedItem, System.Collections.Generic.List`1[T] rightAnswerList) [0x00114] in F:\My Projects\Xamarin\catholicbrain-mobile-app\CatholicBrain\CatholicBrain\Model\BibleOrderGameViewModel.cs:195 </p>
  </blockquote>
  
  <p><strong>MessagingCenter.Send</strong></p>
  
  <pre><code>MessagingCenter.Send&lt;BibleOrderGameViewModel, string&gt;(this, "rightanswer", selectedItem.Answer);
  await PopupNavigation.Instance.PopAsync();
  </code></pre>
  
  <p><strong>MessagingCenter.Subscribe</strong></p>
  
  <pre><code>MessagingCenter.Subscribe&lt;BibleOrderGameViewModel, string&gt;(this, "rightanswer", (s, answer) =&gt;
  {
      answerLabel.Text = answer;
  });
  </code></pre>