I've had my D5100 for a few months and recently purchased the Nikon AF-S DX 35/1.8G lens for it, however I'm having some real problems with the autofocus. I took it with me on a trip without testing it out much beforehand and it probably ruined a few dozen good shots before I realised that it did not reliably autofocus using the viewfinder, only when using the LCD. Even when using single-point autofocus without recomposing the shot it was consistently off, usually with the focus ending up on the hair near the back of the subject's head instead of the eyes and face. Had to make do with the LCD for the rest of the trip which was often a pain due to the slow AF, battery use and glare in sunny weather.
Here is a test I did with it at f1.8, subject distance just over 1m, focusing on the number '2016' near the barcode on the side of the box.
This first image was using the viewfinder, single-point AF: http://postimage.org/image/hxmped8qd As you can see the focus seems to be somewhere around the end of the barcode some 4cm further away.
What is the problem here, is the camera faulty, or is it a bad lens? Or are the results expected due to the shallow depth of field? I tried to do some further testing at higher f-numbers and comparing to the 18-55 kit lens and I think it still doesn't focus correctly but it's much harder to see without the shallow depth of field.