Erwin Mayer
Erwin Mayer

Reputation: 18670

WPF Application very slow to load initial window when launched from Visual Studio

I have a relatively simple WPF application. Whenever I launch it from within Visual Studio 2012 (in Debug or Release mode), it is very slow to start up (can literally take minutes). There is some custom initialization work done (reading files and loading data from a SQLite database), but it should be completed within 1s as it takes less time than that when I launch the application directly by clicking on the Debug/myapp.exe file.

The strange behavior is that if I break the execution and immediately continue ("play" button in the IDE), the window will load instantly. If I press F5 "Start Debugging" the problem will arise, but it will load instantly if I press Ctrl+F5 "Start without debugging".

I am using .NET 4.5 in x86 mode.

I tried profiling using dotTrace Performance profiler but the problem cannot be reproduced this way (it will load instantly).

Do you have any idea about what could be causing this?

Upvotes: 4

Views: 5461

Answers (3)

Dmitry
Dmitry

Reputation: 71

In my case the problem was that for some reason VS doesn't cache symbols for System.Windows.Interactivity.dll and every time I start debug session they're downloaded from server. Navigating to Tools -> Options -> Debugging -> Symbols and selecting "Only specified modules" with empty module list addressed the delay.

Upvotes: 1

Sheridan
Sheridan

Reputation: 69985

On possibility for this slowness could be caused by having too many WPF Trace Settings turned on. If this is the problem, you can tell because the Output Window will be filling with information as the project starts up.

If this is your problem, you can adjust your Trace Settings by going to

Tools > Options > Debugging > WPF Trace Settings

Once you have found the correct section, you can turn the various trace options off and you should see an improvement in speed upon starting the application.

Upvotes: 2

pbalaga
pbalaga

Reputation: 2068

There could be a large amount of breakpoints set in code. Open the Breakpoints window (Debug->Windows) and turn it all off to see, if it's the reason. Or even better, you can delete from disc the .suo user file, which stores breakpoints and session settings.

Another possible reason is a malfunctioning extension. You may want to try to disable some plugins to see, if it works better.

Also, I remember I experienced WPF apps start slowly from VS, if the active tab was graphical window preview.

Upvotes: 1

Related Questions