<p>I've created an assembly and referenced it in my Reporting Services report. I've tested the report locally (works), and I then uploaded the report to a report server (doesn't work).</p>

<p>Here is the error that is thrown by the custom code I've written.</p>

<blockquote>
  <p>System.Security.SecurityException:
  Request for the permission of type
  'System.Security.Permissions.SecurityPermission,
  mscorlib, Version=2.0.0.0,
  Culture=neutral,
  PublicKeyToken=b77a5c561934e089'
  failed. at
  System.Security.CodeAccessSecurityEngine.CheckNReturnSO(PermissionToken
  permToken, CodeAccessPermission
  demand, StackCrawlMark&amp; stackMark,
  Int32 unrestrictedOverride, Int32
  create) at
  System.Security.CodeAccessSecurityEngine.Assert(CodeAccessPermission
  cap, StackCrawlMark&amp; stackMark) at
  System.Security.CodeAccessPermission.Assert()
  at [Snipped Method Name] at
  ReportExprHostImpl.CustomCodeProxy.[Snipped Method Name] The action that failed was:
  Demand The type of the first
  permission that failed was:
  System.Security.Permissions.SecurityPermission
  The Zone of the assembly that failed
  was: MyComputer</p>
</blockquote>

<p>This project is something I inherited, and I'm not intimately familiar with it. Although I do have the code (now), so I can at least work with it :)</p>

<p>I believe the code that is failing is this:</p>

<pre><code>    Dim fio As System.Security.Permissions.FileIOPermission = New System.Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted)
    fio.Assert()
</code></pre>

<p>However, this kind of stuff is everywhere too:</p>

<pre><code>Private Declare Function CryptHashData Lib "advapi32.dll" (ByVal hhash As Integer, ByVal pbData As String, ByVal dwDataLen As Integer, ByVal dwFlags As Integer) As Integer
</code></pre>

<p>I can see either of these being things that Reporting Services would not accommodate out of the box.</p>

[{'answer_id': 37379, 'author': 'Ian Robinson', 'author_id': 326, 'author_profile': 'https://Stackoverflow.com/users/326', 'pm_score': 4, 'selected': True, 'text': '<p>This is how I was able to solve the issue:</p>\n\n<ul>\n<li>strongly sign the custom assembly in question</li>\n<li><p>modify the rssrvpolicy.config file to add permissions for the assembly</p>\n\n<pre><code>                    &lt;CodeGroup\n                        class="UnionCodeGroup"\n                        version="1"\n                        PermissionSetName="FullTrust"\n                        Name="Test"\n                        Description="This code group grants the Test code full trust. "&gt;\n                        &lt;IMembershipCondition\n                                class="StrongNameMembershipCondition"\n                                version="1"\n                                PublicKeyBlob="0024000004800000940100000602000000240000575341310004000001000100ab4b135615ca6dfd586aa0c5807b3e07fa7a02b3f376c131e0442607de792a346e64710e82c833b42c672680732f16193ba90b2819a77fa22ac6d41559724b9c253358614c270c651fad5afe9a0f8cbd1e5e79f35e0f04cb3e3b020162ac86f633cf0d205263280e3400d1a5b5781bf6bd12f97917dcdde3c8d03ee61ccba2c0"\n                            /&gt;\n                    &lt;/CodeGroup&gt;\n</code></pre></li>\n</ul>\n\n<p>Side note: here is a great way to get the public key blob of your assembly\n<a href="http://www.andrewconnell.com/blog/archive/2006/09/15/4587.aspx" rel="noreferrer">VS trick for obtaining the public key token and blob of a signed assembly</a>. </p>\n'}, {'answer_id': 5516520, 'author': 'Noorani raza', 'author_id': 687994, 'author_profile': 'https://Stackoverflow.com/users/687994', 'pm_score': 4, 'selected': False, 'text': '<pre><code>&lt;system.web&gt;\n\n&lt;trust level="Full"/&gt;\n\n&lt;/system.web&gt;\n</code></pre>\n\n<p>try this in web.config</p>\n'}, {'answer_id': 29919076, 'author': 'user3085636', 'author_id': 3085636, 'author_profile': 'https://Stackoverflow.com/users/3085636', 'pm_score': 0, 'selected': False, 'text': '<p>Run your service in administrator mode</p>\n'}, {'answer_id': 54830270, 'author': 'Neil Schurrer', 'author_id': 6104737, 'author_profile': 'https://Stackoverflow.com/users/6104737', 'pm_score': 0, 'selected': False, 'text': '<pre><code> &lt;CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="FullTrust"&gt;\n</code></pre>\n\n<p>For me, the solution was changing the above line in the <code>rssrvpolicy.config</code> from <code>"None"</code> to <code>"FullTrust"</code>.</p>\n'}]
['https://Stackoverflow.com/questions/32428', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/326/']