# Compiler Error ASPIREPERSISTENCE001

<Badge
  text="Version introduced: 13.4"
  variant="note"
  size="large"
  class:list={'mb-1'}
/>

> Resource lifetime types and members are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.

This diagnostic error is reported when a C# AppHost uses the experimental shared resource lifetime APIs. These APIs configure session, persistent, parent-process, and resource-scoped lifetimes across supported resources.

The following APIs and types are protected by this diagnostic:

- `WithSessionLifetime`
- `WithPersistentLifetime`
- `WithParentProcessLifetime`
- `WithLifetimeOf`
- `PersistenceAnnotation`
- `PersistenceMode`

## Example

The following code generates `ASPIREPERSISTENCE001`:

```csharp title="AppHost.cs"
var builder = DistributedApplication.CreateBuilder(args);

var worker = builder.AddExecutable("worker", "node", "../worker", "server.js")
    .WithPersistentLifetime();

builder.Build().Run();
```

## To correct this error

Suppress the diagnostic when you intentionally opt in to the experimental shared lifetime APIs. For container resources, you can instead use the supported container-specific `WithLifetime(ContainerLifetime.Persistent)` and `WithLifetime(ContainerLifetime.Session)` APIs.

Suppress the error with one of the following methods:

- Set the severity of the rule in the _.editorconfig_ file.

  ```ini title=".editorconfig"
  [*.{cs,vb}]
  dotnet_diagnostic.ASPIREPERSISTENCE001.severity = none
  ```

  For more information about editor config files, see [Configuration files for code analysis rules](/diagnostics/overview/#suppress-in-the-editorconfig-file).

- Add the following `PropertyGroup` to your project file:

  ```xml title="C# project file"
  <PropertyGroup>
      <NoWarn>$(NoWarn);ASPIREPERSISTENCE001</NoWarn>
  </PropertyGroup>
  ```

- Suppress the diagnostic in code with the `#pragma warning disable ASPIREPERSISTENCE001` directive:

  ```csharp title="AppHost.cs"
  var builder = DistributedApplication.CreateBuilder(args);

  #pragma warning disable ASPIREPERSISTENCE001
  var worker = builder.AddExecutable("worker", "node", "../worker", "server.js")
      .WithPersistentLifetime();
  #pragma warning restore ASPIREPERSISTENCE001

  builder.Build().Run();
  ```

## See also

- [Configure resource lifetimes](/app-host/resource-lifetimes/)