簡體   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