Friday, January 25, 2008

IList is not serializable in combination with XmlSerializer

Because IList<T> does not implement ICollection (but the generic ICollection<T> instead), the XMLSerializer is not able to serialize the items within the collection. More info on this "bug" can be found here:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105767

Friday, January 4, 2008

Implementing a custom Dispose for a form or usercontrol

Have you ever wanted to implement a custom dispose method for a usercontrol or a form. Trying to override protected void dispose(bool disposing) learns that the designer generated file (mycontrol.designer.cs) already implements this override.

Mark Seemann wrote an intersting approach for dealing with this situation in his blog. It makes use of an Disposer component. A new instance will be created with a reference to a method implementing the custom dispose functionality. This instance is being added to the components collection. When the components get disposed, the this Disposer calls the delegate function with custom dispose logic. That's it.

Thanks Mark for this article.