[英]C# Visual studio 2017 crash when custom user control throw exception
I am learning write my own user controls , and i find that when i throw exception during designer view, Visual studio 2017 will stop working. 我正在学习编写自己的用户控件,我发现当我在设计器视图中抛出异常时,Visual Studio 2017将停止工作。
I created a user control called "ColoredProgressBar" . 我创建了一个名为“ColoredProgressBar”的用户控件。
When AnimationStyle was set to
ProgressBarAnimationStyle.Instantly and
TextStyle was set
ProgressBarTextStyle.AnimationPercentage then the class will throw a InvalidStyleCombinationException(this is my custom exception).
当AnimationStyle设置为
ProgressBarAnimationStyle.Instantly并且
TextStyle设置为
ProgressBarTextStyle.AnimationPercentage时 ,该类将抛出InvalidStyleCombinationException(这是我的自定义异常)。
Here is my code : 这是我的代码:
private void Timer_Tick(object sender, EventArgs e)
{
try
{
// . . .
if (this.AnimationStyle == SUPEXFunction.UI.ProgressBarAnimationStyle.Instantly && this.TextStyle == SUPEXFunction.UI.ProgressBarTextStyle.AnimationPercentage)
{
this.AnimationReachedValue = 0;
InvalidStyleCombinationException a = new InvalidStyleCombinationException("ProgressBarAnimationStyle.Instantly and ProgressBarTextStyle.AnimationPercentage can't exist in same time .");
throw a;
}
// . . .
}
catch (Exception ex)
{
throw;
}
}
public ColoredProgressBar()
{
this.First = true;
this.SetStyle(ControlStyles.UserPaint, true);
this.timer.Interval = 1;
this.timer.Start();
this.timer.Tick += new EventHandler(Timer_Tick);
}
Is this a bug of VS 2017 ? 这是VS 2017的错误吗? How can i fix this without remove the exception ?
如何在不删除异常的情况下修复此问题?
Your code has nothing to make VS 2017 to crash , No infinite loops nothing as I can see. 你的代码没有任何东西可以使VS 2017崩溃,没有无限循环,因为我可以看到。 Try updating your VS2017 with the latest update 2 days ago.
尝试使用2天前的最新更新来更新您的VS2017。 It will work just fine.
它会工作得很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.