Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2006

Tip: Looking for answers? Try searching our database.

CollectionEditor badness in .NET 2.0?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas W. Brown - 21 Aug 2006 23:37 GMT
I have a custom CollectionEditor which has been working nicely for a long
time in .NET 1.1.  We just converted to .NET 2.0, recompiled everything, got
rid of the deprecated function calls, etc...

Now, when I run my app, I can bring up the collection editor initially with
no problems, but when I attempt to bring it up a second time, within the
lifetime of the app, I get a null reference error from my override on
EditValue, right on the call to base.EditValue.  Here is the stack trace:

System.NullReferenceException was unhandled by user code
 Message="Object reference not set to an instance of an object."
 Source="System.Windows.Forms"
 StackTrace:
      at System.Windows.Forms.PropertyGrid.set_SelectedObjects(Object[]
value)
      at
System.ComponentModel.Design.CollectionEditor.CollectionEditorCollectionForm.UpdateEnabled()
      at
System.ComponentModel.Design.CollectionEditor.CollectionEditorCollectionForm.ResumeEnabledUpdates(Boolean updateNow)
      at
System.ComponentModel.Design.CollectionEditor.CollectionEditorCollectionForm.OnEditValueChanged()
      at
System.ComponentModel.Design.CollectionEditor.CollectionForm.set_EditValue(Object value)
      at
System.ComponentModel.Design.CollectionEditor.EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value)
      at
Pathfinder.EditProfileForm.AttribCollectionEditor.EditValue(ITypeDescriptorContext
dc, IServiceProvider sp, Object o) in
C:\VSSBLD\06.09.01\WindowsApplication\Pathfinder\EditProfileForm.cs:line 10055
      at
System.Windows.Forms.PropertyGridInternal.GridEntry.EditPropertyValue(PropertyGridView iva)

Are there some new properties and/or methods on the CollectionEditor in .NET
2.0 that we need to be aware of?

Thanks,
-- TB
Thomas W. Brown - 22 Aug 2006 17:44 GMT
Some additional information...  After debugging awhile I notice that
CollectionEditor is created only once, apparently the first time any instance
of the collection tagged with the Editor attribute is instantiated.  In the
constructor of the CollectionEditor I instantiate a CollectionForm object.

The fact that I'm reusing the underlying CollectionForm every time I try to
edit a collection seems to be at the heart of the problem.  That is, if in my
EditValue override I explicitly Dispose of the current CollectionForm,
instantiate a new one, and initialize it then my problem goes away.

What I don't know is whether this is introducing any subtle problems, or
whether it is, indeed, the right approach?  I've found the documentation for
using collection editors to be slight, at best.  Perhaps someone can point me
to something good, especially for .NET 2.0.

Thanks,
-- TB

> I have a custom CollectionEditor which has been working nicely for a long
> time in .NET 1.1.  We just converted to .NET 2.0, recompiled everything, got
[quoted text clipped - 33 lines]
> Thanks,
> -- TB

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.