如何为清单ETW创建DLL程序集

时间:2019-01-18 06:46:07

标签: c# logging etw

我正在使用ETW。我想使用wevtutil注册事件源。我使用EventSource类创建清单:

string manifestFile = "manifest.xml";
public Registrer()
{
    var assemblyFile = ""; //How to create assembly file???
    var manifestText = EventSource.GenerateManifest(typeof(ExceptionHundler), assemblyFile);

    using (var wr = new StreamWriter(manifestFile))
    {
        wr.Write(manifestText);
    }
    RegistrEventSource();
}
private void RegistrEventSource()
{
    var cmdCommandForCreatingEventSource = $@"wevtutil.exe im ""{manifestFile}""";
    Console.WriteLine(ExecuteCmdCommand(cmdCommandForCreatingEventSource));
}
private string ExecuteCmdCommand(string strCommand, bool runAsAdmin = true)
{
    Process cmd = new Process();
    cmd.StartInfo.FileName = "cmd.exe";
    if (runAsAdmin)
        cmd.StartInfo.Verb = "runus";
    cmd.StartInfo.RedirectStandardInput = true;
    cmd.StartInfo.RedirectStandardOutput = true;
    cmd.StartInfo.CreateNoWindow = true;
    cmd.StartInfo.UseShellExecute = false;
    cmd.Start();
    cmd.StandardInput.WriteLine(strCommand);
    cmd.StandardInput.Flush();
    cmd.StandardInput.Close();
    cmd.WaitForExit();
    return cmd.StandardOutput.ReadToEnd();
}

我的问题是如何为EventSource创建程序集文件? (不使用来自nuget的软件包)。我发现了这个https://docs.microsoft.com/en-us/windows/desktop/WES/message-compiler--mc-exe-,但是某些计算机没有mc.exe。在使用项目的每台计算机上,我都需要修复mc.exe(通过安装SDK)。什么包含程序集文件,有什么方法可以创建它?

0 个答案:

没有答案