gpt4 book ai didi

c# - WiX 安装 EventSource

转载 作者:太空狗 更新时间:2023-10-30 01:04:34 26 4
gpt4 key购买 nike

我基于这个 example 创建了我的事件源.我的事件源如下所示:

[EventSource(Name = "Samples-EventSourceDemos-EventLog")]
public sealed class MinimalEventSource : EventSource
{
public static MinimalEventSource Log = new MinimalEventSource();

[Event(1, Message = "{0} -> {1}", Channel = EventChannel.Admin)]
public void Load(long baseAddress, string imageName)
{
WriteEvent(1, baseAddress, imageName);
}
}

该示例使用代码来模拟安装/卸载过程。从其他一些 SO 问题中,我看到了另一个 example使用事件消息文件安装事件源。

但它缺少一些很好的示例,说明如何安装/注册由 list 定义的 EventSource。我正在调查使用 CustomAction 来做类似的事情:

wevtutil.exe im <EtwManifestManFile> /rf:"EtwManifestDllFile" /mf:"EtwManifestDllFile"

但想知道您是否有任何建议?

最佳答案

经过一番搜索后发现。在 WixUtilExtension 中,有内置支持。引用它并添加命名空间后,这很容易。

以下是 Product.wxs 中的更改:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
...
<Component Id="etwManifest.dll">
<File Id="etwManifest.dll" KeyPath="yes"
Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" />
</Component>
<Component Id="etwManifest.man">
<File Id="etwManifest.man" KeyPath="yes"
Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.man">
<util:EventManifest MessageFile="[etwManifest.dll]" ResourceFile="[etwManifest.dll]"></util:EventManifest>
</File>
</Component>
</Wix>

我必须做的唯一技巧是减少组件 ID 和文件 ID(用于与文件名匹配)的长度以避免以下错误:错误 25540。配置 XML 文件时失败。

关于c# - WiX 安装 EventSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22822183/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com