Tuesday, October 14, 2014

Version dependency sucks

Studying MVC. Working through the book and all is well. Unit tests, Ninject, Moq, &etc &etc. Until it discusses [HiddenInput] in chapter 11. It simply doesn't work. I tried several variations of the attribute with (DisplayValue), without it, set to true, nothing changes. The input still shows up. The scaffolded edit form generates exactly as though the attribute weren't there at all.

So I go back to basics. The projects reference MVC and each other, the model object used by the Razor view is the correct class, all the unit tests are fine. So I start casting around Google. Which just gets me a crapton of tutorials on how to use [HiddenInput] (as though it weren't stark obvious when it's working correctly). At this point I'm tearing my hair out. The closest I can come is a hit on StackOverflow for [HiddenInput] hiding the Display functions in Razor. Not my problem.

At wit's end I use the search function on StackOverflow itself to find "hiddeninput mvc" and ... wait, way down the list here is Q: HiddenInput(DisplayValue = false) Works on one dev machine but not another

This isn't quite my issue but it's more promising than anything else I've looked at. As it happens, the OP had issues with the MVC versions that were being referenced on the two machines. Well. All this is on one machine, sooooo... but there are two different projects involved here and of course projects all have their own references. So I dig MVC up in the reference list and look at properties for it in both projects. Bingo. The domain project references 5.2.2 while the web UI project refernces 5.2.0. Score. Of course, if it's possible to specify a version from within VS I don't know how. I have to open the .csproj files in UltraEdit and find the reference entries for MVC. At least it's XML with a readable schema. Update the web UI with the more current version from the domain project (a simple copy/paste) and we're off!

Except we're not. Ninject spews guts all over my dependency injection because it can't find MVC version 5.2.0. DOH! It all becomse clear now. NuGet-ing Ninject into the web UI project forced MVC to version 5.2.0 however I didn't install Ninject in the domain project so it was left defaulted to the more (most?) current version.

The moral(s) of the story? Version dependency (down to the second point level for crying out loud) sucks. And Google can't always find the most relevant answers.

No comments: