EventSourceCreationData.MachineName Property

 

Gets or sets the name of the computer on which to register the event source.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

Public Property MachineName As String

Property Value

Type: System.String

The name of the system on which to register the event source. The default is the local computer (".").

Exception Condition
ArgumentException

The computer name is invalid.

The MachineName value cannot be an empty string. If the machine name is not explicitly set, it defaults to the local computer (".").

When registering a source on a remote computer, you must have administrative rights on that computer to write the registry values with sufficient permissions.

The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. This example is part of a larger example provided for the EventSourceCreationData class.

Dim mySourceData As EventSourceCreationData = new EventSourceCreationData("", "")
Dim registerSource As Boolean = True

' Process input parameters.
If args.Length > 0
    ' Require at least the source name.

    mySourceData.Source = args(0)

    If args.Length > 1

        mySourceData.LogName = args(1)

    End If
    If args.Length > 2

        mySourceData.MachineName = args(2)

    End If
    If args.Length > 3 AndAlso args(3).Length > 0

        mySourceData.MessageResourceFile = args(3)

    End If

Else 
    ' Display a syntax help message.
    Console.WriteLine("Input:")
    Console.WriteLine(" source [event log] [machine name] [resource file]")

    registerSource = False
End If

' Set defaults for parameters missing input.
If mySourceData.MachineName.Length = 0

    ' Default to the local computer.
    mySourceData.MachineName = "."
End If
If mySourceData.LogName.Length = 0
    ' Default to the Application log.
    mySourceData.LogName = "Application"
End If

SecurityPermission

for calling any member of EventSourceCreationData with full trust. Associated enumeration: PermissionState.Unrestricted

.NET Framework
Available since 2.0
Return to top
Show: