DistributedApplication.Dispose Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Disposes the distributed application by disposing the IHost.
public virtual void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Overridable Sub Dispose ()
Implements
Remarks
Typically developers do not need to worry about calling the Dispose method on the DistributedApplication instance because it is typically used in the entry point of the application and all resources used by the application are destroyed when the application exists.
If you are using the DistributedApplication and IDistributedApplicationBuilder inside unit test code then you should correctly dispose of the DistributedApplication instance. This is because the IDistributedApplicationBuilder instance initializes configuration providers which make use of file watchers which are a finite resource.
Without disposing of the DistributedApplication correctly projects with a large number of functional/integration tests may see a "The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached." error.
Refer to the .NET Aspire testing page for more information on how to use .NET Aspire APIs for functional an integrating testing.