Rediscovering the Obvious

…stumbling in the footsteps of greatness

IDisposable.Dispose isn’t.

without comments

Ok – Rule #1 of .NET programming: If it’s Disposable, dispose it… wrap it in a using statement, call Dispose… SOMETHING!

Easy, once you think that way, nothing to worry about.

Except… when you declare a Mutex, try to dispose it, and get this message:

Error    ‘System.Threading.WaitHandle.Dispose(bool)’ is inaccessible due to its protection level

Now what? looking at the docs: http://msdn2.microsoft.com/en-us/library/system.threading.mutex_methods.aspx shows that the method is indeed listed as protected. I was unaware that you COULD protect an interface implementation… that aside, it seems that it’s even worse that I’m not able to call Dispose on something.

Now that I’ve shared my confusion with the world, can anybody help me figure out what’s going on? If I had more time and energy, I’d pull up reflector, dig out the C# language and .NET runtime specs, and see what I could find. Tonight, however, I’ll leave this as an exercise for my two readers to figure out.

Written by erwilleke

January 9th, 2008 at 11:17 pm

Posted in Uncategorized

Leave a Reply