Ir al contenido

Disposable not disposed (ARCH1101)

Esta página aún no está disponible en tu idioma.

Key dotnet.resource.disposable-not-disposed · Severity warning · Category resource

If an object implementing IDisposable is not disposed, unmanaged resources leak. Wrap local disposable objects with using.

var connection = new SqlConnection(connectionString);
connection.Open();
var command = connection.CreateCommand();
using var connection = new SqlConnection(connectionString);
connection.Open();
var command = connection.CreateCommand();

Wrap the disposable object in a using declaration or using block so it is disposed automatically when it goes out of scope.