Dishwasher fault when directly wired but not when on an extension cord
Just guessing from the information you provided: 

If there is a partial ground in your dishwasher wiring it can draw enough current to trip the breaker. 

When you run it through the extension cord it adds enough resistance to limit the current so it doesn't trip the breaker.

I would suspect if it is an older machine the motor is leaking current through the insulation on the windings.

It may be time for a new one but double check the wiring just in case.

Good luck!