AppDomainSetup.GetConfigurationBytes 方法

定义

返回由 SetConfigurationBytes(Byte[]) 方法设置的 XML 配置信息,这些信息优先于应用程序的 XML 配置信息。Returns the XML configuration information set by the SetConfigurationBytes(Byte[]) method, which overrides the application's XML configuration information.

public:
 cli::array <System::Byte> ^ GetConfigurationBytes();
public byte[] GetConfigurationBytes ();
member this.GetConfigurationBytes : unit -> byte[]
Public Function GetConfigurationBytes () As Byte()

返回

Byte[]

是包含 SetConfigurationBytes(Byte[]) 方法设置的 XML 配置信息的数组,或者,如果尚未调用 SetConfigurationBytes(Byte[]) 方法,则是 nullAn array that contains the XML configuration information that was set by the SetConfigurationBytes(Byte[]) method, or null if the SetConfigurationBytes(Byte[]) method has not been called.

注解

SetConfigurationBytes方法提供了一种方法来重写创建新应用程序域的应用程序的配置信息。The SetConfigurationBytes method provides a way to override the configuration information of an application that creates a new application domain. 中的配置文件信息 value 覆盖应用程序的配置文件信息。The configuration file information in value overrides the configuration file information for the application. 例如,当 Example.exe 应用程序创建新的应用程序域时,它可以覆盖最初从 Example.exe.config 文件中获取的配置信息。For example, when the Example.exe application creates a new application domain, it can override the configuration information originally obtained from Example.exe.config file.

重要

配置文件信息的某些使用者不使用方法所存储的信息 SetConfigurationBytesSome consumers of configuration file information do not use the information stored by the SetConfigurationBytes method. 运行时不强制执行此功能。The runtime does not enforce this. 若要确保在新的应用程序域中覆盖所有配置文件信息,请使用 ConfigurationFile 属性来指定配置文件。To ensure that all configuration file information is overridden in a new application domain, use the ConfigurationFile property to specify a configuration file. SetConfigurationBytes方法会影响程序集绑定。The SetConfigurationBytes method does affect assembly binding.

中的 XML 与 value 普通配置文件中的 xml 相同,不同之处在于它以数组形式存储 ByteThe XML in value is the same as the XML in a normal configuration file, except that it is stored as a Byte array.

若要访问应用程序域的配置字节,请使用 AppDomain.SetupInformation 属性获取 AppDomainSetup 应用程序域的对象,然后使用 GetConfigurationBytes 方法。To access the configuration bytes for an application domain, use the AppDomain.SetupInformation property to get the AppDomainSetup object for the application domain, then use the GetConfigurationBytes method.

适用于