Created
January 11, 2013 07:56
-
-
Save danielmarbach/4508795 to your computer and use it in GitHub Desktop.
"Microsoft.Usage", "CA2202:Do not dispose objects multiple times"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var stream = new MemoryStream()) | |
using (var writer = new StreamWriter(stream) { AutoFlush = true }) | |
{ | |
writer.Write(message.Xml); | |
stream.Seek(0, SeekOrigin.Begin); | |
this.documentSession.StoreAttachement( | |
"someId", null, stream, new RavenJObject { { "Content-Type", "application/xml" }, }); | |
} |
It's equal to the official MSDN documentation: http://msdn.microsoft.com/it-it/library/ms182334.aspx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I had to guess, I'd say stream is being disposed within writer first when writer is disposed, and then again after stream's using statement ends, so just create the stream without a using statement.