How can I make sure in the following code snippet that IDataReader is disposed of if ExecuteReader throws an exception?
using (IDataReader rdr = cmd.ExecuteReader())
{
// use it
}
It makes sense to me that the using syntatic sugar does not call Dispose (since there is no instance to call it on). However, how can I be sure that the scarce resources that are normally allocated by classes that implement IDisposable will be releases?