Reputation: 79
I have written a C# library assembly. It is in a NUGET and contains functions that can be called both from T-SQL scripts (CLR-integration) and from other .net-code. I like the code to be able to check what context it is run in. That is, if a Context Connection (in-process-only connection) is available or not. (If it is I will an entry to a logtable when an exception occours.)
How can a method in a C#-class best determine if the code is executed “in-process” on a SQL Server? If a SqlConnection("context connection=true") can be used? (I do not like to call SqlConnection("context connection=true") and get an System.NotSupportedException if the code is not run in an SQL Server.)
Upvotes: 1
Views: 717