---
title: "Environments"
description: "Learn how to configure your Sentry .NET SDK to tell Sentry about your environments."
url: https://docs.sentry.io/platforms/dotnet/guides/extensions-hosting/configuration/environments/
---

# Environments for Generic Host

Environments tell you where an error occurred, whether that's in your production system, your staging server, or elsewhere.

Sentry automatically creates an environment when it receives an event with the `environment` parameter set.

Environments are case-sensitive. The environment name can't contain newlines, spaces or forward slashes, can't be the string "None", or exceed 64 characters. You can't delete environments, but you can [hide](https://docs.sentry.io/concepts/key-terms/environments.md#hidden-environments) them.

```csharp
// Add this to the SDK initialization callback
options.Environment = "production";
```

*Other available variations of the above snippet: fsharp*

If you don't set it, the SDK uses `SENTRY_ENVIRONMENT`, the .NET host environment or a default. The [Environment option](https://docs.sentry.io/platforms/dotnet/guides/extensions-hosting/configuration/options.md#Environment) describes the order.

To change the environment at runtime, set it on the scope:

```csharp
SentrySdk.ConfigureScope(scope => scope.Environment = "staging");
```

*Other available variations of the above snippet: fsharp*

Everything captured with that scope uses this environment, including logs, metrics, sessions, check-ins and trace propagation. Sessions and traces use the environment from when they start, so changes to `Scope.Environment` don't affect a session or trace that's already running.

##### Changed in Version 7.0.0

In earlier versions, `Scope.Environment` applied only to events and transactions.

Environments help you better filter issues, releases, and user feedback in the Issue Details page of sentry.io, which you learn more about in our [documentation that covers using environments](https://docs.sentry.io/concepts/key-terms/environments.md).
