Calling TimeZoneInfo FROM SQL SERVER 2005 CLR

  • Hi guys,

    See if I can get some help here. Got stuck for a whole day.

    I need to call TimeZoneInfo (.net 3.5) from SQL 2005 CLR Proc, I did the following:

    1. Copy .net 3.5 assembly system.core to the SQL server folder

    2. use the following script the add the assembly into the database

    ALTER DATABASE [database] SET TRUSTWORTHY ON;

    GO

    Create assembly ThreePointFiveAssembly

    from 'C:\Program Files\Microsoft SQL Server\90\Tools\Binn\3.5Assembly.dll'

    with permission_set = unsafe

    3. Create a CLR which calls the TimeZoneInfo class to do some timezone conversion.

    4. Execute and get an error as following:

    Msg 6522, Level 16, State 1, Procedure MessageHistory, Line 0

    A .NET Framework error occurred during execution of user-defined routine or aggregate "MessageHistory":

    System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host.

    The protected resources (only available with full trust) were: All

    The demanded resources were: MayLeakOnAbort

    System.Security.HostProtectionException:

    at StoredProcedures.MessageHistory(SqlDateTime from, SqlDateTime to, SqlInt64 orgUserId)

    does anyone have ideas? Thanks in advance

  • Basically, you are trying to do something that is not allowed for stability reasons in SQL CLR. What exactly are you trying to do? What is the CLR code that you are actually calling?

    Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
    My Blog | Twitter | MVP Profile
    Training | Consulting | Become a SQLskills Insider
    Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]

  • I have solved the problem.

    Please see the following link

    http://social.msdn.microsoft.com/Forums/en-US/sqlnetfx/thread/d0515862-eb87-4a13-bab4-0e343983823a

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply