本文整理汇总了VB.NET中System.Diagnostics.EventSourceCreationData.CategoryResourceFile属性的典型用法代码示例。如果您正苦于以下问题:VB.NET EventSourceCreationData.CategoryResourceFile属性的具体用法?VB.NET EventSourceCreationData.CategoryResourceFile怎么用?VB.NET EventSourceCreationData.CategoryResourceFile使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Diagnostics.EventSourceCreationData
的用法示例。
在下文中一共展示了EventSourceCreationData.CategoryResourceFile属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: EventSourceCreationData
Public Shared Sub CreateEventSourceSample1(ByVal messageFile As String)
Dim myLogName As String
Dim sourceName As String = "SampleApplicationSource"
' Create the event source if it does not exist.
If Not EventLog.SourceExists(sourceName)
' Create a new event source for the custom event log
' named "myNewLog."
myLogName = "myNewLog"
Dim mySourceData As EventSourceCreationData = New EventSourceCreationData(sourceName, myLogName)
' Set the message resource file that the event source references.
' All event resource identifiers correspond to text in this file.
If Not System.IO.File.Exists(messageFile)
Console.WriteLine("Input message resource file does not exist - {0}", _
messageFile)
messageFile = ""
Else
' Set the specified file as the resource
' file for message text, category text and
' message parameters strings.
mySourceData.MessageResourceFile = messageFile
mySourceData.CategoryResourceFile = messageFile
mySourceData.CategoryCount = CategoryCount
mySourceData.ParameterResourceFile = messageFile
Console.WriteLine("Event source message resource file set to {0}", _
messageFile)
End If
Console.WriteLine("Registering new source for event log.")
EventLog.CreateEventSource(mySourceData)
Else
' Get the event log corresponding to the existing source.
myLogName = EventLog.LogNameFromSourceName(sourceName,".")
End If
' Register the localized name of the event log.
' For example, the actual name of the event log is "myNewLog," but
' the event log name displayed in the Event Viewer might be
' "Sample Application Log" or some other application-specific
' text.
Dim myEventLog As EventLog = New EventLog(myLogName, ".", sourceName)
If messageFile.Length > 0
myEventLog.RegisterDisplayName(messageFile, DisplayNameMsgId)
End If
End Sub