I used to be a big fan of WD-40 and put it on practically everything that moved. Here is why I don't use WD-40 for anything I can't easily wipe down. WD-40 is mineral oil in a solvent. Mineral oil, also known as liquid paraffin, dries out relatively quickly and becomes becoming gummy and sticky and it will over time bind up small moving parts like clock works and solenoids.
For small solenoids like those working the electric key locks I liberally spray CRC Electronic Cleaner and then lubricate the moving parts with a very light weight oil like Dextron ATF or 3-in-One. Sometimes I've used a silicone lubricant instead of oil and so far I've not had a problem. I recently discovered Jig-A-Loo, which is a dry invisible teflon spray that works great on all kinds of things, including sticky tent zippers and wooden drawers.
WD-40 is a good for garage door springs and for rust protection on non painted steel and things that don't move much. After all it, was developed to displace water and create a weather barrier on ballistic rockets.