I wrote an article on dealing with dogs a few years ago:
http://www.crazyguyonabike.com/doc/dealingwithdogs
Summary: I have tried the "Dazer" (an ultrasonic dog deterrent) and found that while it does work on some dogs, many appear to not be phased by it at all. I certainly would not rely on it. I have found judicious use of pepper spray to be most effective in dealing with aggressive dogs - I try to use the stronger variety which is usually listed as "law enforcement strength", which has more of the capsaicin than regular "Halt!".
In my experience, this subject always tends to raise strong opinions. My view is that any dog chasing a bicycle is a potential threat, regardless of the dog's intent. It's not just about possible attack - simply having the dog around your wheels when you're in motion on the road is a recipe for disaster (I've seen many stories of people wiping out and having serious accidents from such encounters).
The "other" side believes that dogs are basically harmless and can be dealt with by methods such as body language, voice commands, etc. These people tend to want to minimize the possible dangers posed by chasing dogs, since (in their view) most dogs aren't actually aggressive at all. I get the impression that these people are mostly dog lovers, and they seem to think that those of us who have had problems are just wimps who don't know how to relate to animals or otherwise are just over-reacting. I've even seen arguments to the effect that dogs should be allowed to run free, and if we are in their territory (including the public road running past the dog's residence) then it's our fault if the dog chases us.
I think the truth lies somewhere in between. I like dogs, and I don't spray every dog that comes my way. I try to read the body language. Many times, you can tell in advance how the dog in interpreting the situation. I always slow down when a dog approaches - this has several effects, including reducing the severity of any crashes that might occur, giving myself more time to evaluate the danger, and also reducing the impulse to chase on the dog's part. Much of the time, the dog is just playing, and I have been followed by dogs for a couple of miles or more on quiet country roads, the dog just running quietly alongside me, showing no inclination to get too close. I have no problem with this type of encounter. However, I do always have the pepper spray at hand on my handlebars (on tour, I try to have two cans, on clips that you can buy from Nashbar). It's important to have it immediately close at hand, since encounters tend to develop very quickly, and it's no use at all if you have to go digging around in a bag or pocket.
In my experience, pepper spray always works well. I use the stream variety (the fogger type is too easily dispersed by wind). You can practice with "test" units which have no pepper, but the same liquid as the real units. It's important to get the dog in the mouth, nose or eyes. If you slow down, then you're more likely to be able to retain control of the bike. It's easiest to hit the target when the dog is somewhat behind you - to the side, the stream is dispersed more by your motion.
As I say in the article, I don't like the alternatives - I find shouting to be spotty (it depends on how the dog has been trained), hitting with a stick or lashing out with your foot is dangerous for you (you can easily lose control of the bicycle, and it requires the dog to be very close), ultrasonic devices don't work on all dogs (maybe they are hard of hearing, or maybe they just don't care, I don't know). and so on. Pepper spray is the only solution which, in my experience, works consistently and is also fairly non-confrontational. If the owner gets angry about seeing his dog getting sprayed, then you can just explain that it's very temporary, and in fact you're doing the dog a favor by teaching him not to run out into the road where he might get run over. It's important in such situations not to get angry yourself, otherwise things can rapidly spin out of control.
Neil