locked
.NET 4.0 WPF x64 Slow Application Startup

    Question

  • Hello and thank you to everyone in advance that takes time to assist me.

    I have been having some issues, although not serious or breaking they are rather annoying.  The issues have to do with a 64 bit .NET 4.0 WPF Windows application (even a simple one with one blank window) upon execution, it can be a cold or a warm start and it makes zero difference it starts up at a noticeably slower speed.  Here are my core system specs just as a reference:

    CPU: Intel Core i7 x980 Extreme, GPU: Nvidia GTX 295, Memory: 12 GB OCZ Platinum, HDD: 300 GB Intel X25 SSD RAID 0

    Windows 7 Ultimate x64

    Stated are my new specs, my old computer had the exact same issues with similar specs, so I do not think it is hardware related (I hope).  The following are all the scenarios that I exhausted trying to figure out what is going wrong:

    .NET 3.5:

    All architectures and technologies worked as expected and executed very fast at startup.

    .NET 4.0:

    WinForms Any CPU, x86 and x64 all execute very fast at startup.

    WPF x86 executes very fast at startup.

    WPF Any CPU and x64 much much slower than the tests above, the application takes 5 seconds + to load.

    All of the above tests were compiled with Visual Studio 2010 Ultimate.

    I decided to copy this simple .NET 4.0 WPF x64 application to my laptop which by far has lower specs than my new system and my old system and it executed almost instantly just like it should on my new system.  My two previous computers are different from my laptop in one aspect that I cannot really test, it does not have RAID 0 hard drives.  I sent this same application to a friend of mine who is also a .NET developer who has very similar system specs except he does not utilize a RAID 0 setup and the simple .NET 4.0 WPF x64 application executed instantly on his PC as well.  I compared the service running and applications installed on my current PC and my laptop and they are both very close to the same. My 2 PC's, my laptop and my friends PC are all running Windows 7 Ultimate x64, I am out of ideas and really do not know where to go from here and I am not sure if I disabled something that is causing this issue.

    Any help would be greatly appreciated,

    Justin

    Tuesday, May 04, 2010 10:01 PM

Answers

  • Ok so last year I gave up on this issue, they obviously released an updated or ran a script that fixed it.  This year it is back again after a .NET update, awesome right?

    I am just thankful for people like this:

    http://stackoverflow.com/questions/2947118/wpf-slow-to-start-on-x64-in-net-framework-4-0

    This solution fixed the problem 100% and all is normal now. At a command console run this:

    cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319

    ngen update

    Please Microsoft if you are going to release an update and not update NGEN you need to address this issue quickly, clients running 64 bit apps that update .NET and then have to wait for 20 seconds for an app to start is just unacceptable.  I cannot tell my cleints to run said solution as they will have no idea what I am talking about. I am not sure if this happend because the NGEN services were not running but something did not happen correctly in the chain of events during the .NET update.

    • Marked as answer by fillmorejl Wednesday, April 13, 2011 4:41 PM
    Wednesday, April 13, 2011 4:41 PM

All replies

  • Hi Justin,

    You can refer the Scotte's Blog. Maybe you don't have a GPU(Graphic Processor Unit) in your machine. Since the .NET 4.0 support GPU for its graphic relevant stuff, your CPUs may take more time to calculate the graph and allocate the memory.


    Hope this helpful to you! If you have any further quetions, please feel free to let me know.
    Please mark the right answer at right time.
    Bset Regards,
    Tracy
    • Marked as answer by SamAgain Thursday, May 13, 2010 12:52 AM
    • Unmarked as answer by fillmorejl Thursday, May 13, 2010 4:06 PM
    Tuesday, May 11, 2010 6:16 AM
  • If I am reading you correctly, you asked if I have a graphics card aka GPU (graphics processing unit).  I have a very good GPU in my machine it is an Nvidia GeForce GTX 295, I believe that is overkill for any graphical processing .NET can throw at it.

    I will take a look at Scott's blog, I have before but maybe I missed something. Please let me know if you have any other suggestions.

    I did some further debugging and the application executes instantly, when it goes into the InitializeComponent of the "first" window opened that is where it is extremely slow, any window or control or w/e that opens after that instantly executes and shows.  I am not sure what is going on here other than it loading the XAML that would make it so slow on the first window opening.  Just a note, this is only and issue on a 64 bit WPF .NET 4.0 windows applications, anything else works as expected. I can provide a video to show you the difference of a x86 WPF .NET 4.0 and a x64 WPF .NET 4.0 if you like, the execution time is very noticeably different. 

    Tuesday, May 11, 2010 6:17 PM
  • We temporarily mark a reply, please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Please mark the right answer at right time.
    Thanks,
    Sam
    Thursday, May 13, 2010 12:52 AM
  • It was not an anwser and Scott's blog had nothing to say about my issues.
    Thursday, May 13, 2010 4:08 PM
  • I don't have a solution, but have noticed exactly the same thing, the UI components of .Net 4 WPF apps compiled as x64 run much slower than x86.  I don't think it's GPU related because the same problem is visible over RDP, where only software rendering is being used.  I'm pretty sure MS runs their WPF UI's (Blend, VS 2010) as x86, and that's also a default for new WPF projects - so I'll bet someone there knows what the issue is.
    Monday, May 17, 2010 10:32 PM
  • Ok so last year I gave up on this issue, they obviously released an updated or ran a script that fixed it.  This year it is back again after a .NET update, awesome right?

    I am just thankful for people like this:

    http://stackoverflow.com/questions/2947118/wpf-slow-to-start-on-x64-in-net-framework-4-0

    This solution fixed the problem 100% and all is normal now. At a command console run this:

    cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319

    ngen update

    Please Microsoft if you are going to release an update and not update NGEN you need to address this issue quickly, clients running 64 bit apps that update .NET and then have to wait for 20 seconds for an app to start is just unacceptable.  I cannot tell my cleints to run said solution as they will have no idea what I am talking about. I am not sure if this happend because the NGEN services were not running but something did not happen correctly in the chain of events during the .NET update.

    • Marked as answer by fillmorejl Wednesday, April 13, 2011 4:41 PM
    Wednesday, April 13, 2011 4:41 PM
  • Thanks for the solution although this is not optimal for larger distribution Applications it is still of help.

    WPF & .NET Tutorials
    Thursday, April 21, 2011 3:35 PM