EventLogEntry.ReplacementStrings Property

Gets the replacement strings associated with the event log entry.

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

[MonitoringDescriptionAttribute("LogEntryReplacementStrings")]
public string[] ReplacementStrings { get; }

Property Value

Type: System.String[]
An array that holds the replacement strings stored in the event entry.

This property retrieves only the replacement strings for the entry. To retrieve the full message, read the Message property.

The ReplacementStrings property contains the localized versions of replacement strings that are used in the event log entry. If you provide resource files that contain strings in each target language for your application, you can emit event log messages in the language that is used on that computer. To do that, create an instance of the ResourceManager class for the resource assembly that contains your replacement strings. The first parameter of the ResourceManager(String, Assembly) constructor identifies the resource assembly to be used. Use the GetString method of that instance to supply localized messages for log events. The following code automatically sets the message to the language for the current culture.

ResourceManager LocRM = new ResourceManager("ReplacementStrings.TestStrings", 
      typeof(Program).Assembly);
EventLog e1 = new EventLog("LocTest", "MyMachine", "LocTest");
// Get the string associated with the current culture.
e1.WriteEntry(LocRM.GetString("strMessage"),
   EventLogEntryType.Information);

For information about how to create localized resource files, see Walkthrough: Localizing Windows Forms.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft