title: SSRS External Assembly: SecurityPermission in Preview Pane?
body: <p>ok.. spent 3 days with this, learned a lot about this issue, but still can't quite get around it.</p>
  <p>I have a SSRS Report, that references <strong>external assembly which connects to sql server</strong>, and while previewing this report in Visual Studio, i get the following exception:</p>
  <blockquote>
  <p><strong>SecurityException: Request for the permission of type SqlClientPermission failed</strong></p>
  </blockquote>
  <p>so, i added this code:</p>
  <pre><code>new SqlClientPermission(PermissionState.Unrestricted).Assert();
  </code></pre>
  <p>but this in turn causes this exception:</p>
  <blockquote>
  <p><strong>SecurityException: Request for permission of type SecurityPermission failed</strong></p>
  <p><strong>The zone of the assembly that failed was: MyComputer</strong></p>
  </blockquote>
  <p><strong>from what i've read, this problem should not occur in visual studio preview pane, because  code should run in full trust?</strong></p>
  <p>Never the less, i went ahead and <a href="http://support.microsoft.com/kb/842419" rel="nofollow noreferrer">followed all of the instructions here</a>, in order to give my assembly full trust. I tried adding it by URL, and by Strong Name.</p>
  <pre><code>&lt;CodeGroup class=&quot;UnionCodeGroup&quot;
     version=&quot;1&quot;
     PermissionSetName=&quot;FullTrust&quot;
     Name=&quot;MyNewCodeGroup&quot;&gt;
     &lt;IMembershipCondition class=&quot;UrlMembershipCondition&quot;
        version=&quot;1&quot;
        Url=&quot;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\MyAssembly.dll&quot;/&gt;
  &lt;/CodeGroup&gt;
  </code></pre>
  <p>I also saw <a href="http://blogs.msdn.com/b/bimusings/archive/2005/06/16/429795.aspx" rel="nofollow noreferrer">this post</a>, and tried putting my code group in the place suggested there.</p>
  <p>Furthermore, i tried signing my assembly, and adding a CodeGroup based on strong name (also in My_Computer_Zone.</p>
  <p>I also tried using caspol.exe with:</p>
  <pre><code>caspol -af myassembly.dll
  </code></pre>
  <p>So, i think myassembly runs in full trust (although not 100% sure). <strong>I can't figure out why, i still get these permission errors from Visual Studio Preview pane</strong>.</p>
  <p>What exactly is needed for my code to be able to Assert that sql permission?</p>
  <p><strong>UPDATE</strong></p>
  <p>i set up a local instance of SSRS server. i can deploy my report there, and it works (since i already added full trust for it), but it STILL won't work in VS. This is a temporary work around, but it sucks for development because it takes long to deploy and eats up a ton of ram..</p>