dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.06k stars 1.17k forks source link

Changing "WPF Trace Settings" for Visual Studio debugging has no effect #1970

Open spadapet opened 5 years ago

spadapet commented 5 years ago

image

Minimal repro:

Try again with the project TestBindingsNetFx.sln and the setting will work fine (.NET Framework's WPF)

vatsan-madhavan commented 5 years ago

/cc @debonte

vatsan-madhavan commented 5 years ago

Looks like the wpf-etw.man was not updated for .NET Core.

The .NET Framework manifest can be seen at %windir%\Microsoft.NET\Framework\v4.0.30319\WPF\wpf-etw.man

We need a few things to happen correctly for the trace provider to be registered in .NET Core.

vatsan-madhavan commented 5 years ago
  • Interested parties (for e.g., VS) likely register the manifest (by calling wevtutil just prior to listening to our events).

@debonte, can you help us confirm whether this is true/false?

debonte commented 5 years ago

@vatsan-madhavan I'm not familiar with this feature and unfortunately I'm also not sure who owns it. I can do some detective work if you'd like.

vatsan-madhavan commented 5 years ago

I'm not familiar with this feature and unfortunately I'm also not sure who owns it. I can do some detective work if you'd like.

I'd appreciate that. I'll start some emails re: this as well. with you.

vatsan-madhavan commented 4 years ago

The general problem with wpf-etw.man embedding seems to apply primarily to native events related to the renderer. I'm able to get Data Binding related trace events by just doing this:

<!--   ...    -->
     xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
<!--   ...    -->
    <diag:PresentationTraceSources.TraceLevel>High</diag:PresentationTraceSources.TraceLevel>

But setting the tracing level in VS IDE still doesn't seem to work.

vatsan-madhavan commented 4 years ago

@debonte, I think this has something to do with the IDE ultimately. I haven't been able to puzzle out the exact cause yet, but WPF is generating the right trace events and I can even see it in the IDE if it is enabled in XAML.

It could be that there is some relationship with https://github.com/dotnet/corefx/issues/24829, but I'm doubtful. I'm going to let your team figure this out - let me know if you find that there is something needed from WPF further.

~(should this issue be moved to another repo for better tracking ?)~ on second thoughts, i'd want to keep this issue around to track improvements to the native ETW eventing infrastructure, but i'd sure like to open another issue to track the IDE experience fixups as well.

debonte commented 4 years ago

@vatsan-madhavan Thanks. We already have a Visual Studio bug (989218) filed by @spadapet. Peter, that bug is currently marked as "Blocked by Partner". Sounds like you should be able to investigate based on what Vatsan said above.

jtbrower commented 4 years ago

I probably should have been a better citizen and reported this bug long ago because I began seeing this issue maybe 4-5 months ago. I have always been using the latest VS Previews as well as latest Net Core Pre.

That said, for anyone looking for a half baked work-around, you can use the System.Diagnostics.PresentationTraceSources to change most of the switches through your application code. For example, I have used the following line to silence many of the nuisance binding messages that are usually not binding problems in the first place.

PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error;

However, the reason I landed on this issue report today was because I am trying to debug one of my own issues and want to see the output for routed events. Using the following line had no effect on the output. So my 'trick' above, must not work with all TraceSource's.

PresentationTraceSources.RoutedEventSource.Switch.Level = SourceLevels.Verbose;

Just another day in the office as a WPF developer. Back to print statements :).