we run a distributed system involving many database servers. On each server,
we have a database called Meta which has no tables, only some helper
functions and procs that other procs in other databases call.
In this Meta database, there is an UNSAFE CLR assembly which some of these
helpers use. It's unsafe because it needs to read from the registry for
certain stuff. For this reason, Meta has its TRUSTWORTHY bit set to on.
So here's the problem. Every couple of months, the trustworthy bit in Meta
on one or another server seems to be getting switched off. This causes
errors because the CLR assembly can no longer be loaded.
our ops team thinks this switching may be correlated with creating new
databases, but it's not consistent. usually you can create a new database
and it's no problem, but every so often you create a new one and the
trustworthy bit in Meta gets flipped. Sounds crazy to me but that's what
they say.
When the error does happen, the only foolproof method ops has found to fix
it is to drop and recreate Meta. when they do that, everything is good
again.
It's virtually impossible to debug because it almost always works
correctly - very difficult to debug something with a two month failure
cycle...
Here's the error we see when it happens:
"An error occurred in the Microsoft .NET Framework while trying to load
assembly id 65537. The server may be running out of resources, or the
assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE.
Run the query again, or check documentation to see how to solve the assembly
trust issues."
Has anyone seen anything like this before? Anyone know what might indirectly
be causing the trustworthy bit to flip back off after it's be set on?

Signature
http://elsasoft.org
Adam Machanic - 30 Jun 2008 15:32 GMT
I don't know what to tell you about why the TRUSTWORTHY setting is getting
turned off -- I haven't seen that before. But there is no reason that you
need TRUSTWORTHY to run an UNSAFE assembly. Have you looked at the options
around signing the assembly with a certificate? This eliminates the need
for the TRUSTWORTHY setting and is a much more secure option...
I wrote an article that touches on this topic (in addition to a couple of
related issues), which you can find here:
http://www.code-magazine.com/Article.aspx?quickid=0705051
> we run a distributed system involving many database servers. On each
> server, we have a database called Meta which has no tables, only some
[quoted text clipped - 33 lines]
> indirectly be causing the trustworthy bit to flip back off after it's be
> set on?
Ravi Patel - 14 Aug 2008 00:50 GMT
Hi,
Have you found any resolution to this issue? I am getting similar problem.
The error is same. However, in my case TRUSTWORTHY flag is true even though I
am getting this error.
I created assembly on my dev machine. I restored my database on a different
machine. That seems to be causing this error. I checked the .NET Framework
version. They are same in dev and test machines.
Do you have any clues?
thanks
ravi
> we run a distributed system involving many database servers. On each server,
> we have a database called Meta which has no tables, only some helper
[quoted text clipped - 32 lines]
> Has anyone seen anything like this before? Anyone know what might indirectly
> be causing the trustworthy bit to flip back off after it's be set on?