在不希望运行的代码前加上这句代码就行了。 if (DesignMode) { return; } 转载于:https://www.cnblogs.com/huangcong/archive/2013/06/11/3131599.html