After attaching or restoring a database to SQL Server 2005, you may encounter an error when executing a CLR object.
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65538. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE.
This KB article describes the issue and shows the fix, however it says the bug occurs when the database is attached/restored to a different SQL instance. I’ve encountered the error three times now. In at least one occurrence of the error, it has happened when I’ve restored the database to the same SQL instance.
ALTER DATABASE dbNameGoesHere SET TRUSTWORTHY ON
EXEC sp_changedbowner 'sa'