CounterSet.CreateCounterSetInstance now throws InvalidOperationException if instance already exists
Starting in .NET 5, CounterSet.CreateCounterSetInstance(String) throws an InvalidOperationException instead of an ArgumentException if the counter set already exists.
Change description
In .NET Framework and .NET Core 1.0 to 3.1, you can create an instance of the counter set by calling CreateCounterSetInstance. However, if the counter set already exists, the method throws an ArgumentException exception.
In .NET 5 and later versions, when you call CreateCounterSetInstance and the counter set exists, an InvalidOperationException exception is thrown.
Version introduced
5.0
Recommended action
If you catch ArgumentException exceptions in your app when calling CreateCounterSetInstance, consider also catching InvalidOperationException exceptions.
Note
Catching ArgumentException exceptions is not recommended.