I guess I'm lucky in that I have a pretty good ear for dialogue, most of it comes naturally to me. I usually spend a long time coming up with individual characters in my head, fleshing out their personalities as completely as I possibly can (with the aid of a pretty nice Character Description template I made). If I spend enough time on a character (usually several weeks to a month or two), I can memorize their personality, ideas, and speech patterns to the extent that I can conjure up their "voice" whenever I need to write for them. It's not easy, and it's time consuming, but it's totally worth it in the end, because then dialogue comes naturally, and unless two characters have similar personalities, they never end up sounding the same.
However, I have a difficult time when it comes to very extreme emotions, such as horror, love, or great anger. One thing I try to do when it comes to horror is think of what I would say in a situation like that, if anything, and above all avoid the temptation to a.) make jokes about it, or b.) descend into hyperactive swearing. After writing for a while, I've found that the reason it's hard to write dialogue for characters in horrifying situations is because it's hard to know what to *say* in those situations. If it's hard for you to know what to do when you seriously try to put yourself in your character's shoes, chances are good that it's hard for the character to know what to do as well.
Maybe it's my fault for hanging around too many drama queens, but I have the hardest time when my characters need to express anger without sounding cliche or terribly unrealistic. What I usually do for cases of anger is read the conversations to myself out loud (this is a VERY good idea for editing dialogue in general, btw), and if it doesn't sound natural, I change what sounds wrong until it fits.
Love, I have an easier time with. Generally, it works pretty well if I put myself in their shoes (filtered through their personality and voice, of course) and let the dialogue play itself out. More often than not, it comes out awkwardly (not always in a bad way), and the characters have a hard time expressing their feelings to each other for quite some time. I don't think this is a bad thing at all. In my experience, most relationships (especially prospective homosexual ones in which the sexual orientation of one or both of the people involved is not necessarily a given) tend to be very nervous, awkward affairs until the two people finally work up the nerve to grow into a relationship. In my current novel, Talents, two of my characters are openly gay, and I've found it to actually be a bigger challenge to write for them than any story about closeted guys I've written.
---------------------
EDIT:
---------------------
What am I, a plague or something? I seem to kill topics as soon as I post in 'em... Sorry Comicality...