I'm using ETW. I wanna register my event source with using wevtutil. I created manifest using EventSource class:
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();
}
My question is how to create assembly file for EventSource? (Without using packages from nuget). I found this https://learn.microsoft.com/en-us/windows/desktop/WES/message-compiler--mc-exe- , but some computers doesn't have mc.exe. And in each computer which I'm using my project I need to fix mc.exe (by installing SDK ). What does contains assembly file and is there any way to create this?