StrataFrame Forum

SQL Server CLR Stored Procedure Error

http://forum.strataframe.net/Topic26639.aspx

By Trent L. Taylor - 3/26/2010

Recently I ran into a situation where we were deploying a CLR stored procedure.  It would always work in all development machines, however, when we would attempt to distribute the CLR sproc to a client it would throw the following exception:

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. For more information about this error:

This can come from any number of things.  However, in this case I could place the debug build out there and it would work.  Put the release out there again and it would fail.  After looking at everything BUT the compiler options, I finally looked to see what the differences were between the build versions.  In short, the Optimize Code flag was set on the release build but not on the debug.  Once this flag was removed on teh release, it started working. 

Once this flag was removed, life was good again! Smile