我有一个基于WinForms的应用程序.它正在编译和运行完美.
问题是,从昨天开始,我无法打开主窗体的设计器文件.
起初我以为这是由于我添加了以下调用:
StyleManager.Load("some isl file");
我删除了它,我撤消了对文件的更改,什么都没有.
我得到的错误是来自XmlDocument.LoadXml()调用的“Root元素缺失”.源是实际尝试加载xml文件的方法,但仅在运行时执行此操作.
如果我忽略了这个消息,我得到一个“对象引用未设置为对象的实例”错误,并且忽略这一点我得到“设计器已经加载”.
更新
如果我注释掉了应该读取xml的方法的委托注册(在InitializeComponent()中),则不会发生问题.
我们在我们的解决方案中使用Infragistics,并在堆栈跟踪中提到它们.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at MyApp.Utilities.Xml.Load(String str)
at Editor.Editor.tabFlowView_ActiveTabChanged(Object sender, ActiveTabChangedEventArgs e)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.OnActiveTabChanged(ActiveTabChangedEventArgs e)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.RaiseEvent(UltraTabControlEventId id, EventArgs e)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.set_ActiveTab(UltraTab value)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.OnManagerSelectedTabItemChanging(Object sender, SelectedTabItemChangingEventArgs e)
at Infragistics.Win.UltraWinTabs.TabManager.set_SelectedTabItem(ITabItem value)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.SetSelectedTab(UltraTab tab)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.PerformAction(UltraTabControlAction actionCode)
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.PerformDelayedInitialize()
at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at System.Windows.Forms.Form.ControlCollection.Add(Control value)
at System.Windows.Forms.Design.ControlDesigner.DesignerControlCollection.Add(Control c)
解决方法:
我在表单上使用UserControl时特别发生此错误.如果你正在做一些需要“活动连接”的东西,它会抛出它无法解决的异常.
在你的情况下,它似乎是调用ActiveTabChanged事件,它调用load xml.在加载之前,在xml加载调用之前添加xml.
if (DesignMode) return;
标签:c,winforms,designer 来源: https://codeday.me/bug/20190621/1255935.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。