1

Visual Studio (2010 または 2012) 内で特定のデザイナー ファイルを開こうとすると、回復不能なクラッシュが発生するという問題が発生しています (「Visual Studio が動作を停止しました」)。

これが試行されたときにデバッガーをプロセスにアタッチするとSystem.NullReferenceException、スタック トレースと共にがスローされます。

at System.Windows.Forms.NativeWindow.AddWindowToTable(IntPtr handle, NativeWindow window)
at System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle, Boolean assignUniqueID)
at System.Windows.Forms.Design.ControlDesigner.ChildSubClass..ctor(ControlDesigner designer, IntPtr hwnd)
at System.Windows.Forms.Design.ControlDesigner.HookChildHandles(IntPtr firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.HookChildControls(Control firstChild)
at System.Windows.Forms.Design.ControlDesigner.OnHandleChange()
at System.Windows.Forms.Design.ControlDesigner.DesignerWindowTarget.OnHandleChange(IntPtr newHandle)
at System.Windows.Forms.Control.ControlNativeWindow.OnHandleChange()
at System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle, Boolean assignUniqueID)
at System.Windows.Forms.NativeWindow.AssignHandle(IntPtr handle)
at System.Windows.Forms.NativeWindow.WindowClass.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

この問題は、Windows 8 Enterprise に更新した (現在は SSD を使用している) 開発ボックスで一貫して発生します。Windows 7 Professional の古いボックスでは、一貫してこの動作は見られません。また、この問題は特定のデザイナー ファイルでのみ発生するようですが、その理由はまだ明らかではありません。

これを解決したり、さらに調査したりするための提案はありますか?

4

1 に答える 1

2

この問題を完全に解決したことはありませんが、回避策を設計しました。私がここに提出したバグ レポートには、(MS からの) 詳細情報があります 。 8

要約すると、MS チームは、これは「..コントロールの 1 つの静的初期化が失敗したときのクラッシュ」であると示唆しました。

試行錯誤を通じて問題を絞り込み、問題の原因となっているコントロールを特定し、実行していた初期化を最小限に抑えました (ただし、設計時のみ)。

初期化を最小限に抑えるために、コントロールがデザイナーで使用されているかどうかを確認するプロパティを追加しました。

private bool IsDesignerHosted
{
    get
    {
        if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return true;
        Control ctrl = this;
        while (ctrl != null)
        {
            if ((ctrl.Site != null) && ctrl.Site.DesignMode) return true;
            ctrl = ctrl.Parent;
        }
        return false;
    }
}

.. 次に、このプロパティを使用して、デザイン時のコントロールでのアクティビティを防止します。

于 2014-04-02T12:56:33.917 に答える