Top "Idisposable" questions

IDisposable is an interface within the Microsoft .NET Framework's Base Class Library (BCL).

Code Analysis CA1063 fires when deriving from IDisposable and providing implementation in base class

I have some code that will trigger Code Analysis warning CA1063: CA1063 : Microsoft.Design : Remove IDisposable from the list of …

c# code-analysis idisposable
Stream as a return value in WCF - who disposes it?

Let's say I have the following WCF implementation: public Stream Download(string path) { FileStream stream = new FileStream(path, FileMode.Open, …

.net wcf stream idisposable
What is IDisposable for?

If .NET has garbage collection then why do you have to explicitly call IDisposable?

c# garbage-collection dispose idisposable
Determine if executing in finally block due to exception being thrown

Is it possible to determine if code is currently executing in the context of a finally handler as a result …

c# exception idisposable finally try-catch
Getting rid of nested using(...) statements

Sometimes I need to use several disposable objects within a function. Most common case is having StreamReader and StreamWriter but …

c# idisposable using
Why disposed object doesn't throw exception on using it after disposing?

Is it legal to call a method on disposed object? If yes, why? In the following demo program, I've a …

c# dispose idisposable
How do you prevent IDisposable from spreading to all your classes?

Start with these simple classes... Let's say I have a simple set of classes like this: class Bus { Driver busDriver = …

c# .net garbage-collection dispose idisposable
How to unit test a method with a `using` statement?

How can I write a unit test for a method that has a using statement? For example let assume that …

c# unit-testing idisposable legacy-code
Ninject doesn't call Dispose on objects when out of scope

I was surprised to find that at least one of my objects created by Ninject is not disposed of at …

entity-framework-4 asp.net-mvc-3 ninject idisposable
How do I unit test a finalizer?

I have the following class which is a decorator for an IDisposable object (I have omitted the stuff it adds) …

c# .net unit-testing idisposable finalizer