Reputation: 841
We have a very complex software primarily written using .NET WinForms in C#. Many people have contributed to it. One such contribution was the addition of a Windows Presentation Foundation (WPF)
control hosted in Win Forms. The said control is considered a common control and used in many places in the application.
Everything was working fine till a few days ago when we started seeing inordinate delay in launching the application. The application used to launch in less than 5 minutes, but now takes 20 minutes to launch.
We have been analyzing the situation but have found it very hard to pin down the real issue. We have seen that our misbehaving common control that is used at multiple places, eventually calls the following framework functions:
The time taken by the system functions to perform their duties is shown in the picture above. The system functions take around 1.5 minutes each time the common control is initialized. We use the common control at least 8 times in our application. So, a total of 12 minutes.
Has anyone else seen such issues with WPF controls hosted on WinForms? Any help would be appreciated.
EDIT:
There is an issue with C# Dictionary we use. Getting rid of it by using a List<> solves the delay issue. Microsoft has reproduced the issue at their end. They are working on it. Maybe, our application took C# Dictionary to the edge ;)
Thank you all for providing your inputs.
Upvotes: 0
Views: 646
Reputation: 22702
You can try using the Ngen
:
The Native Image Generator (Ngen.exe)
is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead of using thejust-in-time (JIT) compiler
to compile the original assembly.
If the assemblies of project will be compiled with help of Ngen
, there is no need to run every time JIT-compiler before starting application and loading metadata of using assemblies.
Ngen
will find all of the static dependence of the main assembly and compile them all in a low-level images. These images will be stored in cache of assemblies (GAC), thereby it is possible to reduce application load time.
Upvotes: 0
Reputation: 2941
This is likely to be the Initialization of the WPF control rather than something to do with the ElementHost or the fact that it's hosted within WinForms.
Without seeing the code for the WPF UserControl its hard to tell you what that might be but I would say that the interop of WPF / WinForms is certainly a red herring.
Upvotes: 0