繁体   English   中英

C#Visual studio 2017崩溃时自定义用户控件抛出异常

[英]C# Visual studio 2017 crash when custom user control throw exception

我正在学习编写自己的用户控件,我发现当我在设计器视图中抛出异常时,Visual Studio 2017将停止工作。
我创建了一个名为“ColoredProgressBar”的用户控件。
AnimationStyle设置为ProgressBarAnimationStyle.Instantly并且TextStyle设置为ProgressBarTextStyle.AnimationPercentage时 ,该类将抛出InvalidStyleCombinationException(这是我的自定义异常)。
这是我的代码:

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);
}

这是VS 2017的错误吗? 如何在不删除异常的情况下修复此问题?

你的代码没有任何东西可以使VS 2017崩溃,没有无限循环,因为我可以看到。 尝试使用2天前的最新更新来更新您的VS2017。 它会工作得很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM