| title | Access ClickOnce activation data for .NET | ||
|---|---|---|---|
| description | Learn how to access ClickOnce activation data for .NET Core 3.1, .NET 5 and later. | ||
| ms.date | 01/05/2026 | ||
| ms.topic | how-to | ||
| helpviewer_keywords |
|
||
| author | mikejo5000 | ||
| ms.author | mikejo | ||
| ms.subservice | deployment | ||
| monikerRange | >= vs-2022 |
Starting in the .NET 8.0 version of dotnet-mage, you can access ActivationData properties using environment variables. Using this version of dotnet-mage, you can programmatically:
- Discover the filename for activation based on a custom file association.
- Discover arguments used for activation in the appref-ms file.
The launcher reads the AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData array and sets the appropriate environment variables if the array is non-empty.
The following environments variables are set:
-
ClickOnce_ActivationData_CountIf this variable exists, the value is the count of elements in ActivationData string array.
-
ClickOnce_ActivationData_<n>For each element in array, a new environment variable gets added with a zero-based index, that is:
ClickOnce_ActivationData_0ClickOnce_ActivationData_1The scenarios fixed by this change always use the zero-index element, so the variable will always be
ClickOnce_ActivationData_0, but the code is flexible and is able to pass all activation data to .NET app.
You can read these environment variables to discover ActivationData content, using the following code:
string value = Environment.GetEnvironmentVariable("ClickOnce_ActivationData_0");Previously, for .NET Framework apps, you would read this data using the following code:
string value = AppDomain.CurrentDomain?.SetupInformation?.ActivationArguments?.ActivationData?[0];