17

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:

  • Main->RunInternal(56%)
  • Main->RunInternal->ctor->LoadBaml(32%)

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.

Community
  • 1
  • 1
Roman Nazarkin
  • 2,209
  • 5
  • 23
  • 44
  • 1
    Performance optimization is not really something you can do objectively, without a real context. Unless you provide some code, I'm affraid there is not many people that will be able to help you. – Sisyphe Apr 30 '13 at 07:40
  • 1
    Are there binding errors? They can slow down your application dramatically. – Christian Sauer Apr 30 '13 at 07:41
  • There is no any binding errors and warnings... – Roman Nazarkin Apr 30 '13 at 07:47
  • 2
    http://blogs.msdn.com/b/jgoldb/archive/2007/10/10/improving-wpf-applications-startup-time.aspx - in my limited experience its just WPF being slow, and the solution is to add a splash screen, to provide some indication to the user – dbones Apr 30 '13 at 09:43
  • Does this answer your question? [WPF warm AppDomain startup performance (Application.RunInternal, XamlReader.LoadBaml)](https://stackoverflow.com/questions/7610009/wpf-warm-appdomain-startup-performance-application-runinternal-xamlreader-load) – h.m.i.13 Aug 03 '23 at 07:12

3 Answers3

4

Look at the article mentioned in the comments above.

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

Boklucius
  • 1,896
  • 17
  • 19
  • 4
    I tested as suggested following itme 8 in the mentioned article, it reduces my app startup time from 16-20s to 3s. – Felix Jul 26 '13 at 07:55
  • 2
    Was this referring to http://blogs.msdn.com/b/jgoldb/archive/2007/10/10/improving-wpf-applications-startup-time.aspx ? That seems to no longer exist – StayOnTarget Jul 22 '21 at 12:06
1

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.

user2127480
  • 4,623
  • 5
  • 19
  • 17
1

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.

Alexey Shevelyov
  • 926
  • 1
  • 13
  • 24