We had the same problem with ants in my in-laws dishwasher a couple of years ago.
It was suggested that the ants actually nest in the dishwasher! I find it hard to believe with the tremendous turbulance and heat that is generated inside during the wash cycle.
I suppose that it is possible that ants could get in through the drain line, especially if it has a vacuum breaker installed (air gap)
We solved the problem by spraying underneath the dishwasher, spraying in the basement around plumbing and wiring, and outside the house in the area of the dishwasher.