This one has confused me a little… Attempting to dispose of an XmlReader
XmlReader reader = XmlReader.Create(filePath);
reader.Dispose();
Provides the following error:
‘System.Xml.XmlReader.Dispose(bool)’ is inaccessible due to its
protection level
however the following is fine:
using(XmlReader reader = XmlReader.Create(filePath))
{
}
When I look at the definition in Reflector I can’t understand why I can’t call Dispose

Implementation of Dispose:

Can anyone point out what I’m missing?
The problem is that
XmlReaderuses explicit interface implementation to implementIDisposable. So you can write:However, I’d strongly suggest using a
usingstatement anyway. It should be very rare that you callDisposeexplicitly, other than within anotherDisposeimplementation.EDIT: As noted, this is “fixed” in .NET 4.5, in that it exposes a public parameterless
Disposemethod as of .NET 4.5 as well as the explicit interface implementation. So presumably you’re compiling against .NET 4.0 or earlier (perhaps .NET 2.0 given your tags) but using Reflector against .NET 4.5?