Installer.Context 属性

定义

获取或设置关于当前安装的信息。Gets or sets information about the current installation.

public:
 property System::Configuration::Install::InstallContext ^ Context { System::Configuration::Install::InstallContext ^ get(); void set(System::Configuration::Install::InstallContext ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Configuration.Install.InstallContext Context { get; set; }
member this.Context : System.Configuration.Install.InstallContext with get, set
Public Property Context As InstallContext

属性值

一个 InstallContext,它包含关于当前安装的信息。An InstallContext that contains information about the current installation.

属性

示例

下面的示例演示ContextInstaller类的属性。The following example demonstrates the Context property of the Installer class. Context属性的内容包含有关安装的日志文件的位置、文件的保存位置以及该Uninstall方法所需的信息的位置的信息, 以及在安装时输入的命令行。可执行文件已运行。The contents of the Context property contain information about the location of the log file for the installation, the location of the file to save information required by the Uninstall method, and the command line that was entered when the installation executable was run. 然后在控制台上显示这些内容。These contents are then displayed on the console.

StringDictionary^ myStringDictionary = Context->Parameters;
if ( Context->Parameters->Count > 0 )
{
   Console::WriteLine( "Context Property : " );
   IEnumerator^ myEnum = Context->Parameters->Keys->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      String^ myString = safe_cast<String^>(myEnum->Current);
      Console::WriteLine( Context->Parameters[ myString ] );
   }
}
StringDictionary myStringDictionary = Context.Parameters;
if ( Context.Parameters.Count > 0 )
{
   Console.WriteLine("Context Property : " );
   foreach( string myString in Context.Parameters.Keys)
   {
      Console.WriteLine( Context.Parameters[ myString ] );
   }
}
Dim myStringDictionary As StringDictionary = Context.Parameters
If Context.Parameters.Count > 0 Then
   Console.WriteLine("Context Property : ")
   Dim myString As String
   For Each myString In  Context.Parameters.Keys
      Console.WriteLine(Context.Parameters(myString))
   Next myString
End If

注解

Context属性包含安装信息。The Context property contains installation information. 例如, 有关安装的日志文件的位置、要保存Uninstall方法所需信息的文件的位置, 以及运行安装可执行文件时输入的命令行。For example, information about the location of the log file for the installation, the location of the file to save information required by the Uninstall method, and the command line that was entered when the installation executable was run.

调用InstallCommit、或Uninstall方法的程序设置Context属性, 其中包含方法所需的信息。 RollbackThe program that calls the Install, Commit, Rollback, or Uninstall methods sets the Context property with information that the methods need.

如果安装程序属于安装程序集合, 则父安装程序将在Context调用这些方法中的任何方法之前设置属性。If an installer belongs to an installer collection, the parent installer sets the Context property before calling any of these methods. 父安装程序可通过Parent属性进行访问。The parent installer can be accessed through the Parent property.

适用于

另请参阅