Replace java.lang.IllegalStateException with .Net equivalent InvalidOperationException