Dishwasher senor/latch problem Cannot Start

My dishwasher intermittently cannot turn on. I have to close the door 8-9 times for it to work. I think the latch or sensor has a problem. Which part would I have to buy to replace this and fix it?

Does the door close, latch and open, unlatch normally or does it feel loose? Is it difficult to latch and unlatch? Craig.

Door latches and closes just fine. I see on other forums that it seems the sensor is off by just a millimeter or so. I have dried duct tape to put on the bottom side of the hook/latch, it works until the moisture causes the tape to wear and fail. Does that extra info help you to possible provide a good suggestion?