AddInSecurityLevel 枚举

定义

指定授予外接程序所加载到的应用程序域的信任级别。Specifies the trust level that is granted to the application domain that an add-in is loaded into.

public enum class AddInSecurityLevel
[System.Serializable]
public enum AddInSecurityLevel
type AddInSecurityLevel = 
Public Enum AddInSecurityLevel
继承
AddInSecurityLevel
属性

字段

FullTrust 2

对可读取和写入本地文件系统、创建网络连接以及从注册表中读取的外接程序使用完全信任安全级别。Use the full trust security level for add-ins that are allowed to read and write to the local file system, create network connections, and read from the registry. 通过应用 Unrestricted 字段,此安全级别向外接程序代码访问安全性 (CAS) 授予完全访问权限。This security level grants full access to the add-in's code access security (CAS) by applying the Unrestricted field.

Host 3

使用宿主安全级别为外接程序提供当前授予承载代码的权限。Use the host security level to give the add-in the same permissions currently granted to the hosting code. 此设置有两个用途:This setting has two purposes:

- 它表示主机可以向其加载项授予的最大权限集。- It represents the maximum permission set a host can grant to its add-ins.

- 它允许 ClickOnce 或 Extensible Application Markup Language (XAML) 浏览器应用程序 (XBAP) 主机将其源站点传播到其加载项,以便它们能够与服务器联系。- It allows a ClickOnce or an Extensible Application Markup Language (XAML) Browser Application (XBAP) host to propagate its site of origin to its add-ins, which enables them to contact the server.

Internet 0

对具有低信任级别的外接程序使用 Internet 安全级别。Use the Internet security level for add-ins that have a low trust level.

Intranet 1

对位于公司 Intranet 上的外接程序使用 Intranet 安全级别。Use the Intranet security level for add-ins that are located on a company's intranet. 这些外接程序可以具有较高信任级别,因为服务器和信息都在公司的防火墙内。These add-ins can have a greater trust level because the servers and information are within a company's firewall.

示例

下面的示例激活具有指定信任级别的外接程序。The following example activates an add-in with a specified trust level.

//Ask the user which add-in they would like to use.
AddInToken selectedToken = ChooseAddIn(tokens);

//Activate the selected AddInToken in a new
//application domain with the Internet trust level.
Calculator CalcAddIn = selectedToken.Activate<Calculator>(AddInSecurityLevel.Internet);
            
//Run the add-in using a custom method.
RunCalculator(CalcAddIn);
'Ask the user which add-in they would like to use.
Dim selectedToken As AddInToken = ChooseAddIn(tokens)
'Activate the selected AddInToken in a new
'application domain with the Internet trust level.
Dim CalcAddIn As Calculator = selectedToken.Activate(Of Calculator)(AddInSecurityLevel.Internet)
'Run the add-in using a custom method.
RunCalculator(CalcAddIn)

注解

外接程序系统会激活外接程序, 该外接程序具有与为外接程序的应用程序域指定的信任级别相对应的权限集。The add-in system activates the add-in with the permission set that corresponds to the trust level specified for the add-in's application domain. 该权限集由公共语言运行时的代码访问安全性 (CAS) 配置定义。That permission set is defined by the common language runtime's code access security (CAS) configuration.

不能使用按位 "或" 运算组合此枚举的值。The values of this enumeration cannot be combined by using the bitwise OR operation.

适用于

另请参阅