A prosecutor killed himself as police tried to serve him with an arrest warrant alleging he solicited sex with a minor, authorities said.

Louis “Bill” Conradt Jr., 56, chief felony assistant district attorney for nearby Rockwall County and former district attorney in Kaufman County, died Sunday.

Police forced their way into Conradt’s Terrell home after hearing a gunshot when he refused to answer the door, a police spokesman said. The officers found Conradt with a self-inflicted gunshot wound and he later died at a hospital in Dallas, about 30 miles west of Terrell.

Police in the town of Murphy, in nearby Collin County, said Conradt solicited sex from a decoy posing online as a 13-year-old, said Murphy Police Sgt. Snow Robertson.

NBC News confirmed the sting operation involved "Dateline" and its "To Catch A Predator" series and issued the following statement:

NBC News' "Dateline" was in Texas reporting on its "To Catch A Predator" series in conjunction with online watchdog group Perverted Justice. In the midst of that effort, Rockwall County Assistant District Attorney Louis W. Conradt Jr. contacted a decoy from Perverted Justice who was posing as a 13-year-old boy. Local authorities launched an investigation into Conradt's online communications and went to his home with an arrest warrant. In the course of that investigation, Conradt committed suicide. There was no contact whatsoever between Conradt and "Dateline" at any point in the investigation.

Police said Conradt had not gone to the house but they believed he would.

Murphy Mayor Bret Bishop told the newspaper that he hopes his town won’t be used again as a trap for child predators.

“I think it’s a noble cause, but our police department is hired to serve and protect our citizens, and not to expose them to outside threats,” Bishop said.

Conradt was Kaufman County’s elected district attorney for more than two decades before resigning in 2002 to run for a judgeship. He lost and later took the Rockwall County job.