SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSRS Custom assembly partial/Fully trusted


SSRS Custom assembly partial/Fully trusted

Author
Message
Mike.Hahn
Mike.Hahn
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3407 Visits: 722
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 Cool
I want to win the lotto :-D
I want a gf like Tiffa w00t Oh wait I'm married!:-D
awdmca
awdmca
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 19
I know this is old post but want to know, did you get any solution? I am facing the same issue.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search