看起來MSDN文檔與創建事件日誌以及消息定義文件完全相關。我也失去了如何設置類別(我在3000年的消息定製數字)。EventLogInstaller完整安裝包含類別?
任何人都可以指向我的鏈接或顯示示例代碼如何使這個權利?
看起來MSDN文檔與創建事件日誌以及消息定義文件完全相關。我也失去了如何設置類別(我在3000年的消息定製數字)。EventLogInstaller完整安裝包含類別?
任何人都可以指向我的鏈接或顯示示例代碼如何使這個權利?
你應該開始(如果你還沒有這樣做的話)在這裏:
EventLogInstaller Class (System.Diagnostics)
提供的樣品有你想要做什麼的基礎。總結起來,在程序集中構建一個繼承自System.Configuration.Install.Installer
的公共類(可以是您的應用程序的其餘部分,單獨的DLL或EXE文件所在的同一個DLL),使用RunInstaller
屬性修飾它,然後添加在構造函數中設置代碼:
using System;
using System.Configuration.Install;
using System.Diagnostics;
using System.ComponentModel;
[RunInstaller(true)]
public class MyEventLogInstaller: Installer
{
private EventLogInstaller myEventLogInstaller;
public MyEventLogInstaller()
{
// Create an instance of an EventLogInstaller.
myEventLogInstaller = new EventLogInstaller();
// Set the source name of the event log.
myEventLogInstaller.Source = "NewLogSource";
// Set the event log that the source writes entries to.
myEventLogInstaller.Log = "MyNewLog";
// Add myEventLogInstaller to the Installer collection.
Installers.Add(myEventLogInstaller);
}
}
當你擁有組裝編譯,你可以使用現有的工具InstallUtil
通過Visual Studio命令提示符運行安裝程序代碼。
關於消息定義文件(其中包括類別定義),EventLogInstaller.MessageResourceFile
的MSDN文檔提到您應該創建一個.mc文件,進行編譯並將其作爲資源添加到您的程序集中。挖掘周圍,我發現了一個很好的帖子,應該引導你到最後,在這裏: