我有使用.NET 3.5的ac #Windows Forms应用程序.
我的机器环境如下:
我有一个UserControl派生的自定义控件,其中包含一些其他UserControl.
我在Visual Studio中的Windows窗体设计器中调出主UserControl,然后我开始单击各种嵌入式UserControl并随机更改一些属性,如Text.然后单击" 保存"工具栏按钮.然后,我继续对控件的属性进行更多更改,然后单击" 保存".
在某个时间点之后(这是不可预测的),Visual Studio将显示错误对话框.
WinForms设计器显示一个标题为" Microsoft Visual Studio " 的模式对话框,以及两行消息" 值不能为空.参数名称:上下文 "和一个"确定"按钮.
不幸的是,在通过单击"确定"按钮关闭此对话框后,Visual Studio现在已损坏我的Form的设计器生成的代码.恢复代码的唯一方法是从备份文件.
我发现的唯一解决方法是在" 属性"窗口中为UserControl 将Localizable设置为false.这不是一个长期的解决方法,因为我需要这个UserControl在我们的生产代码中可以本地化.
我的项目相当简单,没有网络服务等.
我尝试使用另一个Visual Studio实例进行调试,以查看是否可以捕获任何异常,但不会生成任何异常.没有任何重要的调试输出.
还有其他人看过这个问题吗?寻找建议.
更多信息...
我能够成功附加Visual Studio的第二个实例,并确定确实抛出了异常.(我必须取消选中"Just My Code"调试选项,并启用符号服务器等).
显然,当我在WinForm Designer中单击" 保存"时,System.ComponentMackl.Design.Serialization.ContextStack.Push(对象上下文)中的System.dll中出现System.ArgumentNullException.因此,context参数为null,这就是问题所在.仍然不知道为什么会发生这种情况.
这是堆栈跟踪:
System.dll!System.ComponentModel.Design.Serialization.ContextStack.Push(object context)+ 0x88 bytes
System.Design.dll!System.ComponentModel.Design.Serialization.ResourceCodeDomSerializer.ApplyCacheEntry(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager = {System.ComponentModel.Design.Serialization.DesignerSerializationManager},System.ComponentModel.Design.Serialization.ComponentCache.Entry entry)+ 0x10e bytes
System.Design.dll!System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.Serialize(System.ComponentModel .Design.Serialization.IDesignerSerializationManager manager = {System.ComponentModel.Design.Serialization.DesignerSerializationManager},object value = {ReveilleSystem.UserInterface.BoldLabel})+ 0xf64 bytes
System.Design.dll!System.Windows.Forms.Design.ControlCodeDomSerializer. Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager = {System.ComponentModel.Design.Serialization.DesignerSerializat ionManager},object value = {ReveilleSystem.UserInterface.BoldLabel})+ 0x83 bytes
System.Design.dll!System.ComponentModel.Design.Serialization.CodeDomSerializerBase.SerializeToExpression(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager = {System.ComponentModel .Design.Serialization.DesignerSerializationManager},object value = {ReveilleSystem.UserInterface.BoldLabel})+ 0x173 bytes
System.Design.dll!System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Serialize(System.ComponentModel.Design.Serialization.IDesignerSerializationManager manager = {System.ComponentModel.Design.Serialization.DesignerSerializationManager},object root = {ReveilleSystem.UserInterface.WizardEditors.EditorBase},System.Collections.ICollection members = {System.ComponentModel.ComponentCollection})+ 0x195 bytes
System.Design.dll! System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformFlush(System.ComponentModel.Design.Serialization.IDesignerSerialization Manager manager = {System.ComponentModel.Design.Serialization.DesignerSerializationManager})+ 0x7e bytes
System.Design.dll!System.ComponentModel.Design.Serialization.BasicDesignerLoader.Flush()+ 0x111 bytes
Microsoft.VisualStudio.Design.dll!Microsoft. VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.Flush()+ 0xa0 bytes
System.Design.dll!System.ComponentModel.Design.DesignSurface.Flush()+ 0x21 bytes
Microsoft.VisualStudio.Shell.Design.dll!Microsoft.VisualStudio. Shell.Design.DesignerWindowPane.OnFlush()+ 0x33字节
Microsoft.VisualStudio.Shell.Design.dll!Microsoft.VisualStudio.Shell.Design.DesignerWindowPane.Microsoft.VisualStudio.Shell.Interop.IVsBatchUpdate.FlushPendingUpdates(uint reserved)+ 0x2a bytes
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.VsTextBufferAdapter.Microsoft.VisualStudio.Shell.Interop.IVsBatchUpdate.FlushPendingUpdates(uint dwReserved)+ 0x97 bytes Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.VsTextBufferAdapter.Save(string pszFilename ="C:\ Temp\Reveille_KofaxMFP - Version 2\Editors\Connectivity.Designer.cs",int fRemember = 1,uint nFormatIndex = 0)+ 0x2f bytes
[Native to Managed Transition]
msenv.dll!DllUnregisterServer()+ 0x10c990 bytes
[下面的框架可能不正确和/或丢失,没有为msenv.dll加载符号] msenv.dll!DllUnregisterServer()+ 0x10cce8 bytes
msenv.dll!DllUnregisterServer() + 0x3e1d6 bytes
[管理到本机转换]
Microsoft.VisualStudio.Editor.Implementation.dll!Microsoft.VisualStudio.Editor.Implementation.VsDocDataAdapter.SaveDocData(Microsoft.VisualStudio.Shell.Interop.VSSAVEFLAGS dwSave,out string pbstrMkDocumentNew,out int pfSaveCanceled) + 0x7e字节[本机到托管转换]
csproj.dll!DllGetClassObject()+ 0x14e87字节msenv.dll!DllUnregisterServer()+ 0x12cbc9字节
msenv.dll!DllUnregisterServer()+ 0x12c940字节
msenv.dll!VStudioTerm()+ 0x4ab22字节
msenv .dll!VStudioMain()+ 0x 1bb97 bytes
msenv.dll!VStudioMain()+ 0x1b74c bytes
msenv.dll!VStudioTerm()+ 0x3ba6d bytes
msenv.dll!VStudioMain()+ 0x1b8e1 bytes
[管理到本机转换]
Microsoft.VisualStudio.Shell.Design.dll!Microsoft. VisualStudio.Shell.Design.Serialization.DesignerDocDataService.LockedDocData.Save()+ 0xbc bytes
Microsoft.VisualStudio.Shell.Design.dll!Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.Microsoft.VisualStudio.Shell.Interop.IVsRunningDocTableEvents. OnAfterSave(uint docCookie)+ 0x124字节
[本机到托管转换]
msenv.dll!DllUnregisterServer()+ 0xd6984字节
msenv.dll!DllUnregisterServer()+ 0xd68f0字节
msenv.dll!DllUnregisterServer()+ 0x12cc40字节
msenv.dll!DllUnregisterServer( )+ 0x12c940字节
msenv.dll!VStudioTerm()+ 0x4ab22字节
msenv.dll!VStudioMain()+ 0x1bb97字节
msenv.dll!VStudioMain()+ 0x1b74c字节
msenv.dll!VStudioTerm()+ 0x3ba6d字节
msenv.dll!VStudioMain( )+ 0x1b8e1个字节
msenv.dll!DllUnregisterServer()+ 0x34e5c个字节
msenv.dll!DllMain()+ 0x5c5 bytes
msenv.dll!DllMain()+ 0x2609d bytes
msenv.dll!DllMain()+ 0x265a7 bytes
msenv.dll!DllUnregisterServer()+ 0x170768 bytes
msenv.dll!DllUnregisterServer()+ 0x1e56f8 bytes
msenv.dll!DllMain()+ 0x1ea7f bytes
msenv.dll!DllMain()+ 0x1e70b bytes
msenv.dll!DllUnregisterServer()+ 0x170894 bytes
msenv.dll!DllUnregisterServer()+ 0x378a71 bytes
msenv.dll!DllUnregisterServer()+ 0x378bb8 bytes
msenv.dll!DllUnregisterServer()+ 0x378aa1 bytes
msenv.dll!6861124f()
[管理到本机转换]
Microsoft.VisualStudio.Shell.10.0.dll!Microsoft.Internal.VisualStudio.PlatformUI.DataSource.Invoke(string verb,object pvaIn ,out object pvaOut)+ 0x21 bytes
Microsoft.VisualStudio.Shell.UI.Internal.dll!Microsoft.VisualStudio.PlatformUI.VsCommand.Execute(object parameter)+ 0x29 bytes PresentationFramework.dll!MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource( System.Windows.Input.ICommandSource commandSource,bool userInitiated)+ 0xb4 bytes
PresentationFra mework.dll!System.Windows.Controls.Primitives.ButtonBase.OnClick()+ 0x54 bytes
PresentationFramework.dll!System.Windows.Controls.Button.OnClick()+ 0x4d bytes PresentationFramework.dll!System.Windows.Controls.Primitives. ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e)+ 0x9e bytes
PresentationCore.dll!System.Windows.UIElement.OnMouseLeftButtonUpThunk(object sender,System.Windows.Input.MouseButtonEventArgs e)+ 0x6c bytes PresentationCore.dll!System.Windows .Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler,object genericTarget)+ 0x31 bytes
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler,object target)+ 0x29 bytes
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo .InvokeHandler(对象目标,System.Windows.RoutedEventArgs routedEventArgs)+ 0x3e个字节
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source = {Microsoft.VisualStudio.PlatformUI.VsButton},S ystem.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs},bool reRaised = true)+ 0xbe bytes
PresentationCore.dll!System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject sender = {Microsoft.VisualStudio.PlatformUI .VsButton},System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs},System.Windows.RoutedEvent newEvent)+ 0x114 bytes
PresentationCore.dll!System.Windows.UIElement.OnMouseUpThunk(object sender,System.Windows. Input.MouseButtonEventArgs e)+ 0xc5 bytes
PresentationCore.dll!System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate genericHandler,object genericTarget)+ 0x31 bytes
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler,对象目标)+ 0x29字节
PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,System.Windows.RoutedEventArgs routedEventArgs)+ 0x3e字节
PresentationCore.dll!System.Windows.EventRoute.Inv okeHandlersImpl(object source = {Microsoft.VisualStudio.PlatformUI.VsButton},System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs},bool reRaised = false)+ 0xbe bytes
PresentationCore.dll!System.Windows.UIElement. RaiseEventImpl(System.Windows.DependencyObject sender = {Microsoft.VisualStudio.PlatformUI.VsButton},System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs})+ 0x79 bytes PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent (System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs})+ 0x41 bytes PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs args,bool trusted)+ 0x2c bytes
PresentationCore.dll! System.Windows.Input.InputManager.ProcessStagingArea()+ 0x1ff bytes
PresentationCore.dll!System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs input)+ 0x45 bytes PresentationCore.dll!System.Windows.Input. InputProviderSite.Repo rtInput(System.Windows.Input.InputReport inputReport)+ 0x62 bytes
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(System.IntPtr hwnd,System.Windows.Input.InputMode mode,int timestamp,System.Windows.Input .RawMouseActions动作,int x,int y,int wheel)+ 0x2c2 bytes PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage(System.IntPtr hwnd = 1837128,MS.Internal.Interop.WindowMessage msg = WM_LBUTTONUP,System. IntPtr wParam = 0,System.IntPtr lParam = 2293872,ref bool handling = false)+ 0x67d bytes
PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd = 1837128,int msg = 514,System.IntPtr wParam = 0,System.IntPtr lParam = 2293872,ref bool handling = false)+ 0x75 bytes WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd = 1837128,int msg = 514,System.IntPtr wParam = 0 ,System.IntPtr lParam = 2293872,ref bool handling = false)+ 0xbe bytes
WindowsBase.dll!MS.Win32.HwndSu bclass.DispatcherCallbackOperation(object o)+ 0x7d bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback,object args,int numArgs)+ 0x53 bytes WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper. TryCatchWhen(对象源= {System.Windows.Threading.Dispatcher},System.Delegate方法,对象指定参数时,INT numArgs,System.Delegate catchHandler = NULL)+的0x42字节WindowsBase.dll中!System.Windows.Threading.Dispatcher.InvokeImpl( System.Windows.Threading.DispatcherPriority priority,System.TimeSpan timeout,System.Delegate方法,object args,int numArgs)+ 0xb4 bytes
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd = 1837128,int msg = 514,System.IntPtr的wParam = 0,System.IntPtr的lParam = 2293872)+量0x104字节
USER32.DLL!gapfnScSendMessage()+ 0x1cf字节
USER32.DLL!gapfnScSendMessage()+ 0x2cf字节
USER32.DLL!gapfnScSendMessage()+ 0x901字节
USER32 .dll!DispatchMessageW()+ 0xf bytes
msenv.dll!DllGetCl assObject()+ 0x37521字节
msenv.dll!的DllGetClassObject()+ 0x375aa字节
msenv.dll!DllCanUnloadNow()+ 0x190f字节msenv.dll!DllCanUnloadNow()+ 0x1840字节msenv.dll!DllCanUnloadNow()+ 0x17a1字节msenv.dll! DllCanUnloadNow()+ 0x176e bytes msenv.dll!DllCanUnloadNow()+ 0x16b0 bytes msenv.dll!VStudioMain()+ 0x78 bytes
devenv.exe!2fcb0637()
devenv.exe!2fcb0fd4()
devenv.exe!2fcb20d8()
devenv.exe !2fcb2148()
的devenv.exe!2fcbea7f()
KERNEL32.DLL!BaseThreadInitThunk()+ 0×12字节
的ntdll.dll!RtlInitializeExceptionChain()+ 0xef字节
ntdll.dll中!RtlInitializeExceptionChain()+为0xC2字节
[UPDATE2]
我想我找到了问题的原因.
根据SLaks的建议,我重新检查了与UserControl相关的X.Designer.cs文件.在X.Designer.cs中声明了其他几个控件(复选框,标签等),但实际上并没有出现在UI中.我怀疑当我使用WinForm编辑器开发我的UserControl时,我可能经历了几个添加/删除子控件的循环,并且在某些时候,这些子控件中的一些在X.Designer.cs文件中是孤立的.我回到了UserControl的非本地化版本(Localizable = False),然后删除了所有孤立的子控件,然后重新编译,然后在WinForm Designer中打开UserControl,然后将Localizable设置回True,并保存所有内容.这似乎现在正在起作用.如果最终不是解决方案,我将来会更新这个.
您在控件中的事件处理程序中有代码,该代码引用了应用程序的其余部分.
在设计器中使用该控件时,此代码将失败(因为其余代码未运行),并引发异常.
您需要检查if (DesignMode),而不是在设计器中运行任何此类逻辑.
若要帮助查找问题,可以启动Visual Studio的第二个副本,将其调试程序附加到第一个副本,并设置Break On All Exceptions.
| 归档时间: |
|
| 查看次数: |
10730 次 |
| 最近记录: |