Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Installer.Context Property

Gets or sets information about the current installation.

[Visual Basic]
Public Property Context As InstallContext
[C#]
public InstallContext Context {get; set;}
[C++]
public: __property InstallContext* get_Context();
public: __property void set_Context(InstallContext*);
[JScript]
public function get Context() : InstallContext;
public function set Context(InstallContext);

Property Value

An InstallContext that contains information about the current installation.

Remarks

The Context property contains installation information. 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.

The program that calls the Install, Commit, Rollback, or Uninstall methods sets the Context property with information that the methods need.

If an installer belongs to an installer collection, the parent installer sets the Context property before calling any of these methods. The parent installer can be accessed through the Parent property.

Example

[Visual Basic, C#, C++] The following example demonstrates the Context property of the Installer class. 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.

[Visual Basic] 
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

[C#] 
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 ] );
   }
}

[C++] 
StringDictionary* myStringDictionary = Context->Parameters;
if (Context->Parameters->Count > 0) {
    Console::WriteLine(S"Context Property : ");
    IEnumerator* myEnum = Context->Parameters->Keys->GetEnumerator();
    while (myEnum->MoveNext()) {
        String* myString = __try_cast<String*>(myEnum->Current);
        Console::WriteLine(Context->Parameters->Item[myString]);
    }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

Installer Class | Installer Members | System.Configuration.Install Namespace | Commit | Install | InstallContext | Parent | Rollback | Uninstall

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.