George M Ceaser Jr
George M Ceaser Jr

Reputation: 1781

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

In my Xamarin Forms project, all day I was receiving this very clear (not the sarcasm) error message

"Value cannot be null Parameter name: type"

Anyone have any ideas what can cause this?

ANSWER!!! Since they won't let me post a new answer

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.

Upvotes: 7

Views: 13074

Answers (3)

NearHuscarl
NearHuscarl

Reputation: 81380

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.

Upvotes: 4

keitaro martin
keitaro martin

Reputation: 897

I had the same error, but different issue. I had a class with:

public int ID { get; set; } = 0;
public string PINLogin { get; set; } = "0";
public bool IsRecordable { get; set; } = false;
public string Picture{ get; set; } = "Picture";
public string Val1{ get; set; } = " ";
public string Val2{ get; set; } = " ";

After a few changes I removed Val1 and Val2, but forgot to remove them from my ListView and that error was show.

Upvotes: 1

George M Ceaser Jr
George M Ceaser Jr

Reputation: 1781

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.

Upvotes: 2

Related Questions