in c#, i am deserializing an object of a type that implements IDisposable with the following statement (for illustration only).
XmlSerializer s = new XmlSerializer(typeof(MyDisposable))
MyDisposable o = (MyDispoable)s.Deserialize(filepath);
afaik, the serializer tries to construct the object using the default ctor and assigning all public properties and fields subsequently. In case there is any exception raised, i won't get my hands on the constructed object.
so, my question is if there is any way to make sure yet allocated resources are freed automatically. i am aware of the Dispose(bool disposing)-'pattern' implementing an explicit finalizer, but i'd feel more comfortable with freeing any resources explicitely (i.e. deterministically).