SSRS Custom assembly partial/Fully trusted

  • Hello wizards,

    Got a major headache with a custom assembly.

    I have a small assembly that reads a regkey to get a network dir path.

    With that path I am trying to get the JPG files in that directory, load it as an image, rotate it 90 degrees and then write it out to an imagebox as a Byte(), setting the image box for database/mime-type:jpg.

    The assembly works in Visual Studio under Fully Trusted in a windows app but when I switch to Partially Trusted it fails.

    I have it testing with partially trusted because when I build the SSRS report in BIDS it seems to be running in partial trust mode.

    I just need to get the security part working.

    This is the error I get in partial trust:

    Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    I've tried <Assembly: AllowPartiallyTrustedCallers>

    Here's one of the VB functions:

    Imports System

    Imports System.Drawing

    Imports System.IO

    Imports System.Security

    Imports System.Security.Permissions

    Public Class test

    Public Shared Function ReadImageFile(ByVal fileName As String) As Image

    'Dim fp As New FileIOPermission(PermissionState.Unrestricted)

    Dim bytes() As Byte = File.ReadAllBytes(fileName)

    Dim img As Image

    Dim ms As MemoryStream

    'fp.Assert()

    ms = New MemoryStream(bytes, 0, bytes.Length)

    ms.Write(bytes, 0, bytes.Length)

    img = Image.FromStream(ms, True)

    ms.Dispose()

    'CodeAccessPermission.RevertAssert()

    Return img

    End Function

    End Class

    ---------------------------------------------------------------
    Mike Hahn - MCSomething someday:-)
    Right way to ask for help!!
    http://www.sqlservercentral.com/articles/Best+Practices/61537/
    I post so I can see my avatar :hehe:
    I want a personal webpage 😎
    I want to win the lotto 😀
    I want a gf like Tiffa :w00t: Oh wait I'm married!:-D

  • I know this is old post but want to know, did you get any solution? I am facing the same issue.

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

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