You are quite welcome :).
I, too, have had similar thoughts with respect to protecting my SQL# project. I have thought that maybe using a static constructor to load a static, readonly, class variable (bool) that could be checked by each function would alleviate the performance hit, though that would still require testing since it is additional steps that need to be take per call to even just check that variable. But the problem with using a static constructor is that there is no SqlContext / Context Connection when it executes since that happens as the class is being loaded. So the timing of when it executes is correct, and happening only once is correct, but no chance of getting data from the DB or even file system. That is, unless you have an EXTERNAL_ACCESS or UNSAFE assembly that can read from the file system or connect back to the host DB via a regular / external connection. However, for my purposes I need something that works with a SAFE Assembly.
One option seems to be that you could reference another Assembly that contains only the license key, but then how to dynamically create and distribute that assembly containing only a single variable?
The only other thought I had been considering was using the application config file (i.e. sqlservr.exe.Config ) as that is readable in a SAFE Assembly, as long as you stick the license key into one of the two pre-defined lists (i.e. ConnectionStrings or AppSettings ). The problem there is that, as far as my testing showed, the config file was not accessible on Linux, and I need something that will work everywhere. Also, now that I think about it, that same concern would be true for the new Managed Instances of Azure SQL Database. So that's 2 of the 3 platforms that SQLCLR works on that wouldn't support this.
So for now I have opted to not worry about it. But it is still an interesting problem that I think about from time to time. If you have any other thoughts about this I would love to hear them.