title: SSRS External Assembly: Failed to load expression host assembly
body: <p>While using external assembly, getting this message in SSRS Report in preview pane. </p>
  
  <blockquote>
    <p><strong>Failed to load expression host assembly. Details: That assembly does not allow partially trusted callers.</strong></p>
  </blockquote>
  
  <p>i've spent a day with this problem (initially started as #Error) </p>
  
  <p>initially calling external assembly was fine. i would get the #Error whenever that external assembly was calling a web service. So i followed <a href="http://support.microsoft.com/kb/842419" rel="nofollow">these directions</a>, and added the code to add permission for calling a service with:</p>
  
  <pre><code>var urlRegEx = new Regex(@"http://mydevserver\.com/.*");
  var p = new WebPermission(NetworkAccess.Connect,urlRegEx);
  p.Assert();
  </code></pre>
  
  <p>the <strong>p.Assert</strong> throws a security exception. so, the last step i did was to attempt to add full trust to the assembly that executes above code with:</p>
  
  <pre><code>cespol -af myAssembly.dll //after strongly signing it
  </code></pre>
  
  <p>that appeared to add full trust to it. but, now i am getting the above message. </p>
  
  <p>not sure what the report is referring to as "Expression host assembly" and/or which assembly exactly is at fault here. I also followed directions in above link to add CodeGroups (url) for 2 assemblies referenced by my report, and added FullTrust to those as well using Microsoft Framework Configuration tool. </p>
  
  <p>One important thing to consider is, initially i could at least execute some simple code in my referenced assembly, (only calling  a webservice would cause #Error). But now, after adding that fulltrust, i can't do that anymore, and keep getting above error.</p>
  
  <p>if i remove full trust from referenced assembly (using castol utility), and try to call calling p.Assert() in it, i get the following error:</p>
  
  <blockquote>
    <p>SecurityException: Request for the permission of type SecurityPermission failed. </p>
  </blockquote>
  
  <p>UPDATE</p>
  
  <p>signing the assembly, is what is causing the main error in this post (Failed to load expression host assembly)</p>