I'm trying register EventSource using Microsoft.Diagnostics.Tracing.EventRegister from nuget. I rebuild my project and its generates manifest.

Debug

After that I run cmd by admin and execute this command:

wevtutil.exe im "ETW loggiing.MyTestSource.etwManifest.man"

Then cmd return this warning

**** Warning: Publisher MyTestSource resources could not be found or are not 
accessible
to the EventLog service account (NT SERVICE\EventLog).

After that I changed file permission

permission

It works, but why this warning occured and how can I fix that with code?

1

There are 1 answers

1
Dilshod K On BEST ANSWER

I fixed this by setting access to dll file from code:

FileInfo fInfo = new FileInfo(path);
        if (fInfo.Exists)
        {
            FileSecurity security = fInfo.GetAccessControl();
            security.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), FileSystemRights.ReadAndExecute, AccessControlType.Allow));
            fInfo.SetAccessControl(security);
        }