You can resolve missing Microsoft.IO.RecyclableMemoryStream or System.Buffers errors by adding the required NuGet package dependencies to the project that runs your MDriven-related code.
When to use this
Add these dependencies when your application reports that it cannot find either of these assemblies:
Microsoft.IO.RecyclableMemoryStreamSystem.Buffers
These assemblies are used to reduce memory pressure. In particular, System.Buffers provides ArrayPool<T>, which lets code rent and return arrays instead of repeatedly allocating new arrays.
Add the required NuGet packages
- Open the project that produces or hosts the application where the missing-assembly error occurs.
- Add the NuGet package named
Microsoft.IO.RecyclableMemoryStream. - Add the NuGet package named
System.Buffers. - Restore the project's NuGet packages.
- Rebuild the project.
- Deploy the rebuilt application and verify that the missing-assembly error no longer occurs.
Add both packages when the error identifies either dependency, because the supplied implementation uses both assemblies.
How array pooling reduces allocations
An array pool is a shared collection of reusable arrays. Instead of allocating a new character array for every operation, code can rent an array from the shared pool.
For example, the following declaration uses the shared character-array pool:
private static ArrayPool<char> _pool = ArrayPool<char>.Shared;
Code can then rent an array when it needs temporary character storage:
char[] buffer = _pool.Rent(1024);
The purpose is to minimize memory pressure by reusing arrays. Ensure that code using a rented array follows the applicable pooling lifecycle, including returning the array when it is no longer needed.
Troubleshooting
| Symptom | Action |
|---|---|
Error states that Microsoft.IO.RecyclableMemoryStream is missing.
|
Add the Microsoft.IO.RecyclableMemoryStream NuGet package, restore packages, rebuild, and redeploy.
|
Error states that System.Buffers is missing.
|
Add the System.Buffers NuGet package, restore packages, rebuild, and redeploy.
|
| The error remains after adding packages. | Confirm that you added the packages to the project that is deployed and that the rebuilt output is the version being run. |
