none
Permission problem with custom assembly in SSRS 2008 (works in 2005) RRS feed

  • Question

  • I am using a custom assembly that needs access to a file. This is the VB code (I cut all of the code out of the function for debugging) :
    Public Class Class1
    
    Public Const FILELOCATION As String = "c:\myDir\myFile.xml"
    
    
    <FileIOPermissionAttribute(SecurityAction.Assert, Read:=FILELOCATION)> _
    Public Shared Function Initialize() As String
    
    Return "Done"
    
    End Function
    
    End Class
    


    I added the following CodeGroup to the execute code group in rsmgrpolicy.config, RSPreviewPolicy.config and rssrvpolicy.config (with appropriate paths in the URL= part)
      <CodeGroup
      class="UnionCodeGroup"
      version="1"
      PermissionSetName="FullTrust"
      Name="MyCustomAssemblyCodeGroup"
      Description="A special code group for my custom assembly.">
      <IMembershipCondition
       class="UrlMembershipCondition"
       version="1"
       Url="C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin\myCode.dll"
      />
      </CodeGroup>
    
    
    _
    I also added a new permission set to all of those files, although I didn't use it anywhere:
     <PermissionSet
      class="NamedPermissionSet"
      version="1"
      Name="xmlFilePermissionSet"
      Description="A special permission set that grants read access to my file.">
      <IPermission
      class="FileIOPermission"
      version="1"
      Read="c:\myDir\myFile.xml"/>
      <IPermission
      class="SecurityPermission"
      version="1"
      Flags="Execution, Assertion" />
     </PermissionSet>
    
    
    I also copied myCode.dll to the following locations:
    C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin
    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies


    When I call the function "initialize"  in my report, I get the following error:

    [rsRuntimeErrorInExpression] The Value expression for the textrun Textbox8.Paragraphs[0].TextRuns[0] contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

     

    I've spent a lot of time trying to figure this out. If I do exactly the same thing in 2005, it works. So what do I have to do in 2008 to make it work?



    • Edited by GariusLupus Friday, May 6, 2011 3:30 PM formatting
    Friday, May 6, 2011 3:24 PM

Answers

  • The problem is solved. It was a problem in the path in the URL section of the codegroup.

     

    In rssrvpolicy.config, the path needs to be:

    C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer

     

    And in RSPreviewpolicy.config, the path needs to be:

    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies


    (I thought that's what I had, but it must have gotten messed up somewhere along the line).
    One other thing you need to do, that I didn't mention in my original post, is in the AssemblyInfo.vb file, you need to add:

    <Assembly: AllowPartiallyTrustedCallers()>

    • Marked as answer by GariusLupus Thursday, June 23, 2011 8:37 PM
    Thursday, June 23, 2011 8:37 PM

All replies

  • Can anyone help with this?
    Monday, May 9, 2011 3:15 PM
  • It's been several days with no answer. Perhaps someone from Microsoft could answer please.
    Tuesday, May 10, 2011 2:28 PM
  • I still need an answer to this, please.
    Thursday, May 12, 2011 7:08 PM
  • Okay, it's been a week since I asked this. Is there a way to bring this to the attention of someone from Microsoft, since I appear to have stumped the good folks on this forum?
    Friday, May 13, 2011 5:11 PM
  • Wow - 240+ views and no replies except my own. I don't feel so bad now for not solving it myself. Anyone even have a wild idea of something I can try or somewhere else I could ask?
    Monday, May 16, 2011 9:23 PM
  • Still need an answer if anyone has one.
    Tuesday, May 24, 2011 2:50 PM
  • Hi GariusLupus,

    I'm having the same exact problem. SSRS2008, custom dll and my custom dll accesses a file to read.
    Same "SecurityPermission" issue.

    Did you ever find out a way of getting this to work???


    SuperJB 
    JB
    Tuesday, June 7, 2011 12:21 PM
  • I'm afraid not. It's been more than a month and more than 550 views and no replies (other than yours and mine). At least now I have company and know it's not just me.

    One work-around I'm using for another project is just doing it in srss2005, but that was a 2005 report to begin with. This one is a new one in 2008, so I don't have that option (unless I start from scratch in 2005).

    Tuesday, June 7, 2011 12:58 PM
  • I have a sort of work-around.... 
    In my case, i want to access my custom dll to read an xml file to implement Globalization in my Reports.
    Everything i have in xml file, i put in to a specific table in my DB and access the table directly.

    But this whole security bull$&/? is really pissing me off! I've searched and searched forums. I have my custom dll in every god dam folder that has anything to do with ReportingServices, Full access everywhere for everyone.... and still the same error over and over again.

    If you ever find out how to fix this, please let me know


    SuperJB 
    JB
    Tuesday, June 7, 2011 1:04 PM
  • The problem is solved. It was a problem in the path in the URL section of the codegroup.

     

    In rssrvpolicy.config, the path needs to be:

    C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer

     

    And in RSPreviewpolicy.config, the path needs to be:

    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies


    (I thought that's what I had, but it must have gotten messed up somewhere along the line).
    One other thing you need to do, that I didn't mention in my original post, is in the AssemblyInfo.vb file, you need to add:

    <Assembly: AllowPartiallyTrustedCallers()>

    • Marked as answer by GariusLupus Thursday, June 23, 2011 8:37 PM
    Thursday, June 23, 2011 8:37 PM
  • Hi GariusLupus,

    Are you able to contact someone from Microsoft? Please do let us know because i am also  stuck into same issue.

    Saurabh 

    Monday, July 11, 2011 11:40 AM
  • Yes, my company is a MS Partner, and we submitted the problem to their service people. That's who found my mistake in the path. They were very fast and helpful, by the way.

     

    I had a second problem, though, after this one. My custom assembly also accessed a database, and that part wouldn't work. I found out (through a quick question to my new MS friends), that you can't use integrated security to connect to the database - you need to log in as an actual user. I don't know if that's your problem, but maybe it will help.

     

    But check your paths. Copy the path to an explorer window and see if you can actually get there. If you can't, shorten the path by one step at a time until you can, then you know where the error is in the path.

     

    Good luck.

    Monday, July 11, 2011 1:18 PM