Roman Nazarkin
Roman Nazarkin

Reputation: 2229

C# WPF Very slow application launch

I've wrote a simple .net WPF application(contains only 2 small windows), but its launch is too slow - about 10-20 seconds!

Profiler says:

Biggest part of application load time - is body of Main->RunInternal function, this isn't my function and i don't know what they makes. Can their execution time somehow be optimized?

Loading Baml markup it takes 32% of all time, but my program have only 3 XAML files and they are containing less than 100 lines of code. Why does this action take so long?

Before asking I have read and tried these tricks, but they didn't help me:

So, how can I speed up the start time of my application?

Thanks.

PS. I've tested this program on two similar computers and the result is a same.

Upvotes: 17

Views: 8906

Answers (3)

Alexey Shevelyov
Alexey Shevelyov

Reputation: 986

My problem was that the project itself was located on the network drive. So the app has to do a whole round trip to the destination drive located 500 miles away from my location and back, compile everything - so surely it was taking all the time. I looked at other issues but this was the one in my case.

Make sure you project is located locally before you try any other things.

Upvotes: 1

user2127480
user2127480

Reputation: 4741

I have the same problem. Google with RunInternal gives me nothing.

I then tried to backup my previous codes and delete assemblies and files until there was only a window left.

Then it worked -- the startup time was shortened from 10 sec to 1 sec!

This time, the profiler showed only System.Windows.Application.Run() instead of RunInternal

It's very strange that for this computer, even after re-importing the bugged(slow) version, it worked correctly! whereas my laptop, which did not go through the fixing above still boots the program for 10+ sec.

Upvotes: 1

Boklucius
Boklucius

Reputation: 1926

Look at the article mentioned in the comments above.

I would suppose it is 8, (Authenticode), it depends on what assemblies you are referencing

Upvotes: 4

Related Questions