I have Windows Forms App in VB.NET it runs fine, I added some code event manually, without designer, like this:
Private Sub bindingNavigatorAddNewItem_Click(sender As System.Object, e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
namesBindingSource.AddNew()
End Sub
And one the Form1.Designer.vb, InitializeComponent method this code
AddHandler Me.BindingNavigatorAddNewItem.Click, AddressOf Me.bindingNavigatorAddNewItem_Click
Now, even though the form runs fine, and the event is executed correctly; the form fails at design time with the error:
Value cannot be null. Parameter name: objectType
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.GetRuntimeType(Type objectType) at System.ComponentModel.TypeDescriptionProvider.GetRuntimeType(Type reflectionType) at Microsoft.VisualStudio.Design.MultiTargetingContextProvider.GetRuntimeType(Type objectType) at Microsoft.VisualStudio.Design.Serialization.CodeDom.HandlesClauseManager.GetFieldType(String fieldName, Type documentBaseType) at Microsoft.VisualStudio.Design.Serialization.CodeDom.HandlesClauseManager.GetReferencedComponentType(String componentName, CodeTypeDeclaration codeTypeDecl, ITypeResolutionService loader, IDictionary& cache) at Microsoft.VisualStudio.Design.Serialization.CodeDom.HandlesClauseManager.ParseHandlesClauses(CodeTypeDeclaration codeTypeDecl, Boolean updateCache) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnMethodPopulateStatements(Object sender, EventArgs e) at System.CodeDom.CodeMemberMethod.get_Statements() at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
Now, I notice it doesn't happen if I bind the event by designer, instead of manually.
But I still need to do it manually, because it will eventually be generated by some DTE automation code.
Also if after the error I press the link "Ignore and Continue" it shows the form fine at design time, but why it is failing in the first place?