EventSourceCreationData.MachineName Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define o nome do computador no qual registrar a origem do evento.
public:
property System::String ^ MachineName { System::String ^ get(); void set(System::String ^ value); };
public string MachineName { get; set; }
member this.MachineName : string with get, set
Public Property MachineName As String
Valor da propriedade
O nome do sistema no qual registrar a origem do evento. O padrão é o computador local (".").
Exceções
O nome do computador é inválido.
Exemplos
O exemplo de código a seguir define as propriedades de configuração de uma fonte de evento de argumentos de linha de comando. Os argumentos de entrada especificam o nome de origem do evento, o nome do log de eventos, o nome do computador e o arquivo de recurso de mensagem de evento. Este exemplo faz parte de um exemplo maior fornecido para a EventSourceCreationData classe.
EventSourceCreationData mySourceData = new EventSourceCreationData("", "");
bool registerSource = 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];
}
if (args.Length > 2)
{
mySourceData.MachineName = args[2];
}
if ((args.Length > 3) && (args[3].Length > 0))
{
mySourceData.MessageResourceFile = args[3];
}
}
else
{
// Display a syntax help message.
Console.WriteLine("Input:");
Console.WriteLine(" source [event log] [machine name] [resource file]");
registerSource = false;
}
// Set defaults for parameters missing input.
if (mySourceData.MachineName.Length == 0)
{
// Default to the local computer.
mySourceData.MachineName = ".";
}
if (mySourceData.LogName.Length == 0)
{
// Default to the Application log.
mySourceData.LogName = "Application";
}
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
Comentários
O MachineName valor não pode ser uma cadeia de caracteres vazia. Se o nome do computador não estiver definido explicitamente, ele usará como padrão o computador local (".").
Ao registrar uma fonte em um computador remoto, você deve ter direitos administrativos nesse computador para gravar os valores do Registro com permissões suficientes.