c# - 如何为清单 ETW 创建 dll 程序集
问题描述
我正在使用 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 )。什么包含程序集文件,有什么方法可以创建它?
解决方案
推荐阅读
- google-cloud-platform - GCP:如何获取计算引擎访问令牌?
- python - 如何并行化复杂的for循环
- apache-kafka - 如何使用 JmxTool 访问 Kafka 消费者指标(consumer-fetch-manager-metrics)?
- javascript - 将一个简单的函数修改为自包含的
- html - 显示 Bootstrap Dismissible 警报
- python - H2OValueError:文件 train_FD004.txt 不存在
- c# - 正则表达式包含所有特殊字符
- mysql - Express-handlebars 将多个数据集路由到一页
- java - 比 O(n^2) 更快地找到堆深度
- sql - 确保自动导入例程正确运行的最佳实践是什么