Search code examples
c#winformsdesigner

Designer loading error with c#/.Net 3.5 on VS 2008


I have a WinForms based application. It's compiling and running perfectly. Problem is, ever since yesterday, I can't open the main form's designer file.
At first I thought that this is due to me adding the following call:

StyleManager.Load("some isl file");

I removed it, I undid changes to the file, and nothing.

The error I get is "Root element is missing" that comes from XmlDocument.LoadXml() call. The source is a method that actually tries to load an xml file, but only does so during runtime.

If I ignore this message I get an "Object reference not set to an instance of an object" error, and by ignoring this too I get "the designer is already loaded".

Update

If I comment out the delegate registration of the method that's supposed to read the xml (in InitializeComponent()), the problem does not occur.

We use Infragistics in our solution, and there's mentioning of them in the stack trace.

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)


Solution

  • I have this error happen in particular when using UserControls on a form. If you're doing something that requires an "active connection" it throws the exception that it's unable.

    In your case it appears to be calling the ActiveTabChanged event, which is calling the load xml. Prior to the load the xml add prior to the xml load call.

    if (DesignMode) return;
    

    DesignMode