title: Error: "Inheritance security rules violated" while Sandboxing
body: <p>I'm creating an application that will run code in a sandboxed environment.  This environment should only allow the untrusted code to process resources that it is explicity given and return a defined data type.  I'm using the principals found in this article to setup the sandbox:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/bb763046.aspx" rel="nofollow">How to: Run Partially Trusted Code in a Sandbox
  </a></p>
  
  <p>I also have some code that will need to run inside the sandboxed environment.  Unfortunately, when I try to setup the type to run inside the sandbox I'm getting the following error:</p>
  
  <blockquote>
    <p>Inheritance security rules violated by type: 'MyTypeRunningInSandbox'. Derived types must either match the security accessibility of the base type or be less accessible.</p>
  </blockquote>
  
  <p>I'm not sure why I would get this error as both the base type and the derived type were created by me, and neither should be more or less secure than the other.</p>
  
  <p>My Application Strucure (to help you understand):</p>
  
  <pre><code>TypeLoader class
     \
      Trusted Sandbox Manager (i.e. sets up a the new sandbox)
       \              (the error is happening in this class while creating the 
        |             new app domain) 
        |
        |Untrusted Sandbox Manager (i.e. runs the untrusted code)
  </code></pre>
  
  <p>If you compare my solution with regard to the Microsoft article above, my code is failing on the equivalent to the following line:</p>
  
  <pre><code>ObjectHandle handle = Activator.CreateInstanceFrom(
  newDomain, typeof(Sandboxer).Assembly.ManifestModule.FullyQualifiedName,
         typeof(Sandboxer).FullName );
  </code></pre>
  
  <p>Any thoughts on how to troubleshoot this issue?</p>