Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Form Error Value cannot be null. Parameter name: type

All day I was receiving this very clear (not the sarcasm) error message "Value cannot be null. Parameter name: type" I was hitting my head against the wall slowly decomposing my code until I could figure out the exact cause of the problem. After much tedious deconstruction I discovered that I had an error in my GestureRecognizers section. The problem was that I accidentally typed Command to try to pass a parameter instead of CommandParameter.

My original code generating the error looked like this.

<Label.GestureRecognizers>
    <TapGestureRecognizer Tapped="Value_Tapped" Command="language" />
</Label.GestureRecognizers>

The corrected code is this:

<Label.GestureRecognizers>
    <TapGestureRecognizer Tapped="Value_Tapped" CommandParameter="language" />
</Label.GestureRecognizers>

I hope this helps someone else in the future.

like image 967
George M Ceaser Jr Avatar asked Nov 27 '16 01:11

George M Ceaser Jr


2 Answers

I managed to fix the issue after following every steps from this post:

  • Clean the solution.
  • Close Visual Studio.
  • Delete the bin and obj directories from each project in the solution (YourProject, YourProject.Android, YourProject.iOS)
  • Restart Visual Studio.
  • Build each project individually - NOT rebuild the solution.
  • Rebuild Solution.
like image 162
NearHuscarl Avatar answered Nov 06 '22 10:11

NearHuscarl


It appears if you try to set the Command property to something Xamarin Forms does not know you will get this error. If you get the error I suggest double checking all the non-intelisense correct parameters in your code.

like image 22
George M Ceaser Jr Avatar answered Nov 06 '22 11:11

George M Ceaser Jr