Main form designer error


When trying to load the main form (EuropeEngulfedNETForm.cs) in design mode within Visual Studio, the following error occurs: "To prevent possible data loss before loading the designer, the following errors must be resolved: Object reference not set to an instance of an object."
This is probably (?) due to converting the project from VS2005 to VS2008.
Call Stack:
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)


tscheffel wrote May 27, 2010 at 4:04 PM

I think I've narrowed the problem down to the MapControl user control. That control has 3 constructors. The parameterless constructor (which I believe gets called when an enclosing form is opened in the VS designer) does not initialize the gameStateInfo instance. Still researching.

tscheffel wrote May 28, 2010 at 2:46 AM

I have positively narrowed the problem down to the MapControl user control. If I comment out the MapControl instance then the main form will open in the Visual Studio form designer without errors. And, I'm fairly certain the problem lies with the IGameStateInfoProvider member.

To recap the problem: the default (parameterless) constructor for the MapControl object does not initialize its IGameStateInfoProvider member. This causes the member to be null when loaded into the form designer.

Solution: not resolved yet.

tscheffel wrote May 30, 2010 at 4:09 PM

I am not yet sure how to properly handle the situation with the MapControl user control. The control is embedded in the main form but it has a reference to the main form, essentially creating a circular reference.

wrote Feb 13, 2013 at 7:17 PM