title: .NET 4, AllowPartiallyTrustedCallers attribute, and security markings like SecurityCritical
body: <p>I'm new C# and am trying to understand the <a href="http://msdn.microsoft.com/en-us/library/dd233103.aspx" rel="noreferrer">new security features of .NET-4</a>.</p>
  
  <p>To fill in some details, I'm currently trying to update AutofacContrib.Moq to work with the latest Moq. I had no problems doing this for .NET-3.5 and under. But in .NET-4 the security restrictions result in numerous security exceptions.</p>
  
  <p>Moq has a a single method, <code>GetObjectData</code>, that's marked with the <a href="http://msdn.microsoft.com/en-us/library/system.security.securitycriticalattribute.aspx" rel="noreferrer">SecurityCritical</a> attribute. AutofacContrib.Moq has the <a href="http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute.aspx" rel="noreferrer">AllowPartiallyTrustedCallers</a> attribute set which is the source of the exceptions. It seems that rather than adding the <code>SecurityRules</code> attribute with a SecurityLevel of 1, I'd be better off removing <code>AllowPartiallyTrustedCallers</code> attribute. I believe this makes the assembly SecurityTransparent by default, which may not be sufficient (though the AutofacContrib.Moq unit tests pass).</p>
  
  <p>My main question at the moment is whether assemblies targeting .NET-4 should ever use the AllowPartiallyTrustedCallers attribute?  But, given that I definitely don't understand everything yet, what details should be considered when working with assemblies that are security marked? Do I need to explicitly mark my assembly with security attributes in those places it uses, directly or indirectly, something that's marked <code>SecurityCritical</code>?</p>