2013-09-23 27 views
1

我们遇到了一个问题,试图在Visual Studio(2010或2012)中打开特定设计器文件将导致其无法恢复崩溃('Visual Studio已停止工作')。Visual Studio设计器崩溃(在Windows 8上)

附加一个调试器时,这个尝试的过程中抛出一个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企业(和现在使用的固态硬盘)。 Windows 7 Professional上的旧盒子始终如此而不是表现出这种行为。这个问题似乎也只是出现在特定的设计器文件上,尽管它还不清楚为什么。

有没有人有任何建议来解决这个问题,或进一步调查?

+1

在http://connect.microsoft.com/VisualStudio提交错误 – Florian

+0

您是否尝试安装VS2012 Update 4的RC? – magicandre1981

回答

2

从来没有完全解决过这个问题,但确实设计了一种解决方法。有一个在错误报告我提交更多资讯(从MS): http://connect.microsoft.com/VisualStudio/feedback/details/802088/designer-file-causing-crash-since-update-to-windows-8

综上所述,MS团队认为这是一个“..crash当控件的一个静态初始化是失败”

通过试验和错误,我们缩小了问题的范围,以确定引起问题的控制,然后最小化了它正在执行的初始化(但仅在设计时间内)

为了最小化初始化,我们添加了一个属性来检查控制器正在设计中使用:

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

..然后在设计时使用此属性来防止控件上的活动。