Eve Online has been one of the few games to address this problem head on, by adding a sanctioned way to buy in game money for real money. Their system works by allowing players to buy 30 day game cards, then those codes from the cards can be turned into an in game item that can be sold to other players. The market system in Eve isn't connected between stations either, so if you want to sell it for a higher price, you have to risk transporting the item in your ship to sell at another station. During transport, it's very possible to be attacked by another player and lose your ship and it's contents. So not only did CCP help combat gold farmers, they integrated the concept completely into the normal gameplay.
There was an article about that sometime last year. Some guy had a lot of game codes he was transporting and ended up dying and they were lost. I wish I remember the exact amount, but want to say it was over $20k worth.