In any proceeding brought by the Attorney General to secure compliance with the provisions of Sections 12584 to 12587, inclusive, or any regulation issued pursuant thereto, the judgment, if in favor of the state, shall provide that the person having the responsibility or duty to comply with such provisions on behalf of any charitable trust or charitable corporation, shall pay the reasonable expense necessarily incurred by the state in the investigation and prosecution of such action.