i would like to detect if MARS (multiple active results set) is active on the current connection, in order to check for a misconfiguration in a function which needs MARS support.
Either using a TSQL command, or a .NET SQL Server Native Client api method.
You could check the connections ConnectionString property for the presence of the MultipleActiveResultSets attribute and if it is there make sure it is set to true.
Depending on your code usage you can also check the SqlConnection.ServerVersion property to check for MARS support. The major number should be >= 9. (SQL Server 2005 and greater). This would be useful if your code is use on different SQL server versions.
The SqlConnectionStringBuilder could also be used in reverse (maybe a weird idea), it has a MultipleActiveResultSets property.