Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.Diagnostics.Tracing.TraceEvent - Missing Dependency Microsoft.Win32.Registry #755

Closed
joshdean2000 opened this issue Oct 3, 2018 · 8 comments

Comments

@joshdean2000
Copy link

When calling dispose on TraceEventSession it throws an exception because it's unable to load this assembly. This is using a .Net 4.6.1 app.

To resolve have to add this NuGet package to the project. It should be listed included as dependency so it's automatically added when needed.

This started with version 2.0.25

@mehmetilker
Copy link

Relatively same, so for now I am not opening new issue.

I am getting following exception randomly when I call session.EnableProvider("...")
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Win32.Registry, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
Currently I am using 2.0.26 and I guess started after 2.0.22.

@vancem
Copy link
Contributor

vancem commented Oct 31, 2018

I can't reproduce this issue. Ideally you include a trivial VS solution that demonstrates the problem.

Note that TraceEvent has support for both NetStandard and .NET 4.5. You say that this is running on .NET 4.6.1. My guess is that what is happening is that your solution is asking for the NetStandard flavor of Microsoft.Diagnostics.Tracing.TraceEvent.dll (which has a reference to Microsoft.Win32.Registry.dll (if you had built against the V4.5 version it would 'know' that the registry functions are in mscorlib)), and the NetStandard 'forwarding' DLLs are not operating correctly.

If so, this is likely not an issue with TraceEvent but NetStandard support. You can work around it by targeting .NET 4.5.

But that is just a guess. having an actual repro solution so I get exactly what is needed to reproduce the problem will help make progress.

I SUSPECT that what is going on is that you

@mateialexandru
Copy link

Hi Vance,

Here is a sample when using WPF targeting .NET Framework 4.7.2
TraceEventWin32RegistryBug.zip

@guidovaroli
Copy link

Hi Vance
a stack trace my help to reproduce ?

here stack of exception with fusion log detail from an winform application targeting 4.7.2

Exception: Could not load file or assembly 'Microsoft.Win32.Registry, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Exception Type: System.IO.FileNotFoundException
Error loading file : Microsoft.Win32.Registry, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
See Fusion Log for details : WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:
at Microsoft.Diagnostics.Tracing.Extensions.ETWKernelControl.ResetWindowsHeapTracingFlags(String sessionName, Boolean noThrow)
at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.Stop(Boolean noThrow)

@vancem
Copy link
Contributor

vancem commented Dec 7, 2018

Sorry for the delay, you gave me this repro quite a while ago.
I can reproduce the problem with your repo.

I at least have a work-around for you If you right click on your 'References' item in the Solution Explorer and select 'Manage Nuget Packages' and add a reference to the Microsoft.Win32.Registry nuget package (V 4.5 is fine), then it will add a Microsoft.Win32.Registry.dll to your bin\ directory and it should work (It did for me).

I understand the problem a bit better now, but still need to figure out the best solution.

@vancem
Copy link
Contributor

vancem commented Dec 12, 2018

A fix for this is now on nuget.org as release https://github.com/Microsoft/perfview/releases/tag/T2.0.31

Thanks for helping getting this fixed.

@vancem vancem closed this as completed Dec 12, 2018
@ConstantinDulu
Copy link

I still see this error when running from a UWP project.
Installing the additional nuget package does address the issue though.

The main issue I have is that the app fails with ACCESS_DENIED when running as UWP as there is no way to run as elevated.
Was anybody successful using this library from a UWP app?

@brianrob
Copy link
Member

@ConstantinDulu, I suspect that you are trying to create and start a TraceEventSession. Unfortunately, this isn't possible via a UWP app as far as I'm aware. This is because control of ETW requires elevation and I'm not aware of any way to elevate within a UWP app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants