You raise a good point!
Barletta, a strong conservative - did very poor against Casey. The unfortunate reality is that there are more democrats than republicans registered in PA. Another problem Barletta faced was Casey's strong name recognition and strong support from so-called 'traditional' democrats.
The questions I would ask about Barletta's loss to Casey is whether the PA republican party and the RNC provided Barletta the support that he needed? Did Toomey provide Barletta his strong support; did he vigorously campaign for him? Did the republican party surround Barletta with a winning campaign staff and winning levels of $$?
What did the autopsy reveal about Barlett's Senate campaign and loss to Casey?
Barletta had some pretty mediocre ratings among a lot of conservative organizations that rate House and Senate members over the years. That should have served him well in a state where Democrats outnumber Republicans among registered voters.