Redigera

Dela via


InstallContext Constructors

Definition

Initializes a new instance of the InstallContext class.

Overloads

InstallContext()

Initializes a new instance of the InstallContext class.

InstallContext(String, String[])

Initializes a new instance of the InstallContext class, and creates a log file for the installation.

InstallContext()

Initializes a new instance of the InstallContext class.

public:
 InstallContext();
public InstallContext ();
Public Sub New ()

Examples

Note

This example shows how to use one of the overloaded versions of the InstallContext constructor. For other examples that might be available, see the individual overload topics.

When the program is invoked without any arguments, an empty InstallContext is created.

// There are no command line arguments, create an empty 'InstallContext'.
myInstallObject->myInstallContext = gcnew InstallContext;
// There are no command line arguments, create an empty 'InstallContext'.
myInstallObject.myInstallContext = new InstallContext();
' There are no command line arguments, create an empty 'InstallContext'.
myInstallObject.myInstallContext = New InstallContext()

Remarks

This overload does not create a log file for the installation.

Applies to

InstallContext(String, String[])

Initializes a new instance of the InstallContext class, and creates a log file for the installation.

public:
 InstallContext(System::String ^ logFilePath, cli::array <System::String ^> ^ commandLine);
public InstallContext (string logFilePath, string[] commandLine);
new System.Configuration.Install.InstallContext : string * string[] -> System.Configuration.Install.InstallContext
Public Sub New (logFilePath As String, commandLine As String())

Parameters

logFilePath
String

The path to the log file for this installation, or null if no log file should be created.

commandLine
String[]

The command-line parameters entered when running the installation program, or null if none were entered.

Examples

This example is an excerpt of the example in the class overview of InstallContext class.

When "/LogFile" and "/LogtoConsole" are specified, the InstallContext is created by passing the respective arguments to InstallContext.

// Create an InstallContext object with the given parameters.
array<String^>^commandLine = gcnew array<String^>(args->Length - 1);
for ( int i = 0; i < args->Length - 1; i++ )
{
   commandLine[ i ] = args[ i + 1 ];
}
myInstallObject->myInstallContext = gcnew InstallContext( args[ 1 ],commandLine );
// Create an InstallContext object with the given parameters.
String[] commandLine = new string[ args.Length ];
for( int i = 0; i < args.Length; i++ )
{
   commandLine[ i ] = args[ i ];
}
myInstallObject.myInstallContext = new InstallContext( args[ 0 ], commandLine);
' Create an InstallContext object with the given parameters.
Dim commandLine() As String = New String(args.Length - 2) {}
Dim i As Integer
For i = 1 To args.Length - 1
   commandLine(i-1) = args(i)
Next i
myInstallObject.myInstallContext = _
   New InstallContext("/LogFile:example.log", commandLine)

Remarks

If the installation uses Installutil.exe (Installer Tool), this constructor creates a log file at the specified path and parses the array of command-line parameters into the Parameters property. If a log-file path is specified in the command-line parameters, it is used to create the file. If the log file argument is not specified in the command line, the value of the logFilePath parameter is used. To suppress the creation of a log file, pass the "/logfile= " command-line parameter.

Notes to Callers

Pass your default log-file path in the logFilePath parameter when you call this constructor. This is the where the log file is created, unless the /logfile command-line parameter is used when the installation executable is run.

See also

Applies to