How to embed an Instrumentation Manifest without losing the AssemblyInfo?

StackOverflow https://stackoverflow.com/questions/21814380

  •  12-10-2022
  •  | 
  •  

문제

My goal is to embed an instrumentation manifest in a .NET assembly. To do that, I compile the manifest file (.man) into a resource file (.rc) using mc.exe, then compile the .rc file into a .res file using rc.exe. Finally, I use the Win32Resource element in the .csproj file to embed the .res file into my assembly.

The problem is that once I use the Win32Resource element, I lose the versioning info generated by the AssemblyInfo.cs file.

How can I both embed the instrumentation manifest and keep the versioning info in the resulting assembly?

도움이 되었습니까?

해결책

Please use the Microsoft.Diagnostics.Tracing.EventSource NuGet Package to use ETW in .Net.

Here is a sample class:

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

This is much better compared to the old C++ way.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top