The Woman in Black by E. C. Bentley
Trent's Last Case (US title The Woman in Black) is actually the first novel in which the gentleman detective Philip Trent appears. The novel is a detective story whose unique place in the history of detective fiction is because it is at the same time the first great sentiment of that genre itself: not only does Trent fall in love with a prime suspect - usually considered a no-no - he too, after painstakingly gathering all the evidence, he draws all the wrong conclusions. Convinced that he has tracked down the killer of a business tycoon who was killed in his mansion, during dinner he is told by the real culprit what errors in the logical deduction of the solution to the crime he committed. Hearing what really happened, Trent vows that he will never again attempt to dabble in crime detection.