Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Method AddRange not found exception in Visual Studio designer
 

Method AddRange not found exception in Visual Studio designer

Hello

We have a generic base collection class ObjectCollection(Of T) inherited form System.ObjectModel.Collection(Of T). It provides just general collection for objects but raises events prior and after changes. We often inehrit from this collection to get specific collection. One of them is ButtonCollection (inherited as ObjectColection(Of Button)). In our base form, used as ancestor for all our forms property Buttons As ButtonCollection. DesignerSerializationVisibility is set to Content. When we edit this property in Visual Studio form designer, everything is OK. Collection editor Pops up, where we add and set up buttons and everything is correctly written to .Designer.vb file. But whe we rebuild our project, form designer refreshes itself and fails to load with error: Method 'ButtonCollection.AddRange' not found. AddRange is standard method to add multiple objects into collection at once. From this point designer is messed up and we have to restart Visual Studio.

This error occurs only in Visual Studio designer. Everything is OK at runtime - of course AddRange() method exists.

Does anybody know what could be a problem? It is VERY annoying and basically we cannot design our forms.


Thanks, Stano

We use updated Visual Studio 2008 with SP1, .NET framework 3.5 SP1, (though project is in .NET 2).


Call stack from designer is:

at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)

at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

Satano  Thursday, May 07, 2009 2:45 PM

Hi Santano,

You have mentioned the ButtonCollection type is inherited from the ObjectCollection(Of Button) and the ObjectCollection(Of T) is inherited from the Collection(Of T).

I don't see the Collection(Of T) class has a "AddRange" method.

I performed a test based on your description. In my test, the items are added to the ButtonCollection using the Add method rather than the "AddRange" method in the InitializeComponent method.

If possible, please reproduce the problem in a simple project and send it to me to have a look. My email address is v-lliu@microsoft.com.

Sincerely,
Linda Liu


Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Thursday, May 14, 2009 10:12 AM

You can use google to search for other answers

Custom Search

More Threads

• MainMenu Control
• Problem getting focus in control inheriting Panel
• Manipulating data from two excel sheets into one using Visual Studio 2005
• Docking Order
• Delete property value with custom UITypeEditor
• Label inside usercontrol re-initializes whenever I build/load the designer.
• Create Code for Handler/delegate of control
• serching listview
• Custom component that will create and add controls to a form
• Property grid and Datagrid in .Net 2.0