'What might cause a performance drop after migrating a WPF project from 3.5 to 4.0?

When I compile my application to target version 4.0 of the framework, UI performance goes straight to hell. For instance, opening an Expander that contains a Grid with maybe 6 Label and TextBox controls goes from near-instantaneous to 3-4 seconds, and there's then a visible delay between the time it renders the grid's second column (the editable controls) and the first (their labels).

If I drop back to 3.5, everything goes back to the way it was: there's virtually no lag between opening an Expander and seeing its contents, and the labels in the grid render so quickly that you can't see it happen.

There are, of course, a million things that could conceivably cause this. I guess what I'm hoping someone can tell me is where I should start looking. I don't especially need to upgrade to 4.0 right now, so I don't have a huge incentive to dig into profiling this beast, but if I'm accumulating technical debt while I sit here at 3.5 I'd like to know about it.



Solution 1:[1]

That is indeed a strange occurrence, I've now migrated two heavy WPF3 applications to 4 without issues (ignoring a couple of resource problems) but if anything its improved our runtime performance quite nicely.

While not a direct answer to your question, I followed the write up by Paul Harrington when we moved over to WPF 4. I also spent quite a bit of time with the WPFPerf tool - I realise you don't want to profile!

The only other thing I can think of is the change of Graphics Rendering Tiers in WPF4 vs WPF3.5. This caused one of the testers to realise his test box was running in Software Rendering (hardware acceleration was disabled due to a bad graphics driver update). RenderOptions.ProcessRenderMode is your friend here to check. But I'd guess you'd be running on a decent bit of kit anyway :)

Solution 2:[2]

You're probably using a DLL compiled for .NET 3.5 which forces lots of 3.5 DLLs to get loaded as soon as one of the types that needs it gets constructed. Check to make sure all of your DLLs are 4.0-only.

Solution 3:[3]

Maybe you're using or misusing one of the new features of WPF 4.0 ?

I'd start by investigating this list and see if anything remotely applies to the app.

Good luck

What's new in WPF 4.0 (list)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Glorfindel
Solution 2 Ana Betts
Solution 3 keyle