如何在不丢失AssemblyInfo的情况下嵌入检测清单?

问题描述 投票:1回答:1

我的目标是在.NET程序集中嵌入检测清单。为此,我使用mc.exe将清单文件(.man)编译为资源文件(.rc),然后使用rc.exe将.rc文件编译为.res文件。最后,我使用.csproj文件中的Win32Resource元素将.res文件嵌入到我的程序集中。

问题是,一旦使用Win32Resource元素,我将丢失AssemblyInfo.cs文件生成的版本控制信息。

如何既嵌入检测清单,又将版本控制信息保留在生成的程序集中?

.net etw
1个回答
2
投票

请使用Microsoft.Diagnostics.Tracing.EventSource NuGet软件包在.Net中使用ETW。

这里是一个示例类:

[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);
    }
}

与旧的C ++方法相比,这要好得多。

© www.soinside.com 2019 - 2024. All rights reserved.