PartialTrustVisibilityLevel 枚举


指定用 AllowPartiallyTrustedCallersAttribute (APTCA) 特性标记的代码的默认部分信任可见性。Specifies the default partial-trust visibility for code that is marked with the AllowPartiallyTrustedCallersAttribute (APTCA) attribute.

public enum class PartialTrustVisibilityLevel
public enum PartialTrustVisibilityLevel
type PartialTrustVisibilityLevel = 
Public Enum PartialTrustVisibilityLevel


NotVisibleByDefault 1

已为部分信任审核该程序集,但是它在所有主机中对部分信任的代码均不可见。The assembly has been audited for partial trust, but it is not visible to partial-trust code in all hosts. 若要使程序集对部分信任的代码可见,请将该程序集添加到 PartialTrustVisibleAssemblies 属性。To make the assembly visible to partial-trust code, add it to the PartialTrustVisibleAssemblies property.

VisibleToAllHosts 0

程序集始终可以由部分信任的代码调用。The assembly can always be called by partial-trust code.


PartialTrustVisibilityLevel作为属性设置参数传递到AllowPartiallyTrustedCallersAttribute.AllowPartiallyTrustedCallersAttribute构造函数。PartialTrustVisibilityLevel is passed as a property setting parameter to the AllowPartiallyTrustedCallersAttribute.AllowPartiallyTrustedCallersAttribute constructor. 如果没有参数传递给构造函数, 则默认值为 VisibleToAllHosts。If no parameter is passed to the constructor, the default is VisibleToAllHosts.

通过将部分受信任的程序集添加到其应用程序域的PartialTrustVisibleAssemblies属性, 可将这些程序集标识为 NotVisibleByDefault。You enable partially trusted assemblies that are identified as NotVisibleByDefault by adding them to the PartialTrustVisibleAssemblies property of their application domain. 如果启用的程序集直接或间接引用了其他部分受信任的程序集 (NotVisibleByDefault), 则还应启用其他程序集。If you enable an assembly that references (directly or indirectly) other partially trusted assemblies that are NotVisibleByDefault, those other assemblies should be enabled as well.

第一次加载用于指定PartialTrustVisibilityLevel且符合代码共享条件的 APTCA 库时, 它将加载到共享域中。When an APTCA library that specifies a PartialTrustVisibilityLevel and that is eligible for code sharing is loaded for the first time, it is loaded into the shared domain. 只要将同一PartialTrustVisibilityLevel程序集加载到其他域中, 就会共享该程序集。Whenever that assembly is loaded with the same PartialTrustVisibilityLevel into another domain, it will be shared. 但是, 如果使用其他PartialTrustVisibilityLevel程序集加载该程序集, 则不会共享该程序集。However, if the assembly is loaded with a different PartialTrustVisibilityLevel, it will not be shared.