As MemoryStream is an unmanaged resource does it always have to be disposed?
Given:
1) A method is invoked.
2) A MemoryStream object is created (Mem
See here Avoiding Problems with the Using Statement
Looked at the IL and using does this:
try
{
}finally
{
((System.IDisposable)obj).Dispose();
}
Which means your stream will get disposed no matter what but the exception(if it occurs in the try block) will remain on the stack so it may crash you app if you don't take care.
So: "The reference on the MemoryStream object is therefore lost. Does this scenario need a try/finally-block (or using-statement)?" - Its the same
Now its really interesting what would happen if the Dispose method fails for some reason- you got an IE security hole:) Kidding:)