wordwalker
Auror
Here's one different approach, besides the problems of manufacturing and society: if you want a more heavy-handed answer, the world could have a microrganism that eats one of the components of gunpowder, leaving what's left useless or even unstable. This might be a good plot twist if your hero's an engineer who's sure he can get everything right-- but you want something totally new to him to make it Just Not Work until he figures that out too. Or if some genius in the world's past (or right now) created this bug to prevent guns.
Another answer is magic. The more wizards are able to develop specialized spells, the harder they'd work at making spells to disrupt aim, then something to ruin gunpowder, and ultimately to detonate it. Guns might turn out to be more dangerous to their user-- but only when a wizard's around, and not if you use cannons to batter the wizard's town from outside his range.
Another answer is magic. The more wizards are able to develop specialized spells, the harder they'd work at making spells to disrupt aim, then something to ruin gunpowder, and ultimately to detonate it. Guns might turn out to be more dangerous to their user-- but only when a wizard's around, and not if you use cannons to batter the wizard's town from outside his range.