Soenneker.MemoryStream.ManualClose 11.0.710

Prefix Reserved
dotnet add package Soenneker.MemoryStream.ManualClose --version 11.0.710
                    
NuGet\Install-Package Soenneker.MemoryStream.ManualClose -Version 11.0.710
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.MemoryStream.ManualClose" Version="11.0.710" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.MemoryStream.ManualClose" Version="11.0.710" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.MemoryStream.ManualClose" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.MemoryStream.ManualClose --version 11.0.710
                    
#r "nuget: Soenneker.MemoryStream.ManualClose, 11.0.710"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.MemoryStream.ManualClose@11.0.710
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.MemoryStream.ManualClose&version=11.0.710
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.MemoryStream.ManualClose&version=11.0.710
                    
Install as a Cake Tool

Soenneker.MemoryStream.ManualClose

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

A MemoryStream whose Close and Dispose calls can be temporarily ignored when another API incorrectly assumes ownership of a caller-owned stream.

Installation

dotnet add package Soenneker.MemoryStream.ManualClose

Usage

AllowClose defaults to true, so the stream behaves like a normal MemoryStream unless closing is explicitly blocked.

var stream = new ManualCloseMemoryStream
{
    AllowClose = false
};

try
{
    await WritePayload(stream);

    // This dependency calls Dispose on the supplied stream.
    await SendWithoutOwnership(stream);

    // The stream remains usable because closing was blocked.
    stream.Position = 0;
    await SaveCopy(stream);
}
finally
{
    stream.AllowClose = true;
    stream.Dispose();
}

Always restore AllowClose and dispose in a finally block. While closing is blocked, a using statement or an early Dispose call does not release the stream's buffer.

This type is useful only when an API closes a stream it does not own and offers no leave-open option. Prefer the dependency's native leaveOpen setting when one exists. Do not change AllowClose concurrently with disposal; the property does not provide synchronization.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.710 41 11/18/2026
11.0.709 228 11/11/2026
11.0.708 502 10/27/2026
11.0.706 153 10/26/2026
4.0.705 455 10/14/2026
4.0.704 105 10/14/2026
4.0.699 114 10/12/2026
4.0.698 111 10/12/2026
4.0.697 124 10/11/2026
4.0.696 293 9/24/2026
4.0.695 223 9/15/2026
4.0.694 125 9/12/2026
4.0.693 162 8/30/2026
4.0.692 127 8/29/2026
4.0.691 328 7/27/2026
4.0.690 147 7/16/2026
4.0.689 1,325 6/18/2026
4.0.688 233 6/5/2026
4.0.687 152 6/5/2026
4.0.685 507 3/12/2026
Loading failed

Configure .NET CI defaults and daily source scans