If the attorney general or any district attorney shall, in any manner, consult, advise, counsel, or defend, within this state, a person charged with a crime or misdemeanor or the breach of a penal statute, he shall, on conviction, be fined in a sum not exceeding five hundred dollars, be removed from office, and rendered incapable thereafter of filling any office of profit or honor in this state.