ploeh / Hyprlinkr

A URI building helper library for ASP.NET Web API
MIT License
198 stars 34 forks source link

NullReferenceException #26

Closed Xiot closed 10 years ago

Xiot commented 10 years ago

ScalarRouteValueQuery throws a NullReferenceException on line 109 (var value = lambda.Compile().DynamicInvoke().ToString();) when you pass null for the value of one of the parameters. In my limited testing, removing the ToString got around the issue although I didn't look into why the ToString was there in the first place.

ploeh commented 10 years ago

Thank you for reporting this.

ToString is required because the parameter value might not be a string; it might as well be an integer, or a complex object. If removing ToString solved your problem, my guess is that in your case, the parameter was already a string.

Given that a parameter could be of any type, it's unclear to me how to handle this scenario. Perhaps inserting null into the resulting dictionary would be OK, because the Web API infrastructure would be able to handle this automatically, but I haven't looked into this yet.

ploeh commented 10 years ago

This should now be resolved. It's live as Hyprlinkr 1.0.1.