【问题标题】:How to embed an Instrumentation Manifest without losing the AssemblyInfo?如何在不丢失 AssemblyInfo 的情况下嵌入 Instrumentation Manifest?
【发布时间】:2014-02-16 16:57:55
【问题描述】:

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

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

如何同时嵌入检测清单并在生成的程序集中保留版本信息?

【问题讨论】:

    标签: .net etw


    【解决方案1】:

    请使用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++ 方式相比,这要好得多。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-07
    相关资源
    最近更新 更多