VB Migration Partner

KNOWLEDGE BASE - General


Previous | Index | Next 

[HOWTO] Using the NGEN tool to speed up the startup phase of a migrated .NET application

VB Migration Partner users may have found that migrated .NET application take several seconds to display their first form. This short article explains the cause for this performance degradation and how you can avoid it.

All .NET applications – regardless of the language they are written with or the fact that they have been migrated from VB6 by means of VB Migration Partner – are actually compiled in IL (Intermediate Language), which is a CPU-agnostic language that must be converted into Intel x86 or x64 opcodes before the application can actually run. The transformation from IL into actual CPU opcodes is performed by the JIT (Just-in-time) compiler, which is part of the .NET Framework environment.

In general, the JIT compiler – also known as “the JITter” – processes one method at a time, therefore the conversion usually occurs in the background and without a noticeable loss of performance. This is the usual case for business components that have no user interface.

For the JITter to convert a method, however, it is necessary that also all the classes/methods that that method uses or invokes are also JITted. This creates a performance penalty with Windows Forms application, because the very action of displaying a form with a few controls on it requires the JIT-compilation of a large portion of the System.Windows.Forms.dll assembly. The situation becomes a bit worse – but not remarkably worse – with projects that have been migrated from VB6, because also a portion of the CodeArchitects.VBLibrary.dll assembly needs to JIT-compiled before displaying the first form.

The solution to this performance problem can be found in the .NET Framework SDK, in the form of the NGEN tool. In addition to speeding up the startup phase, the NGEN tool can also help in reducing the memory footprint of an assembly, You can read more about the NGEN tool here.

In its simplest syntax, you just use NGEN with the install option, followed by the path of the .NET executable file that you want to optimize, as in this example:

     NGEN install c:\myexes\myapp.exe

When running NGEN on a compiled .NET assembly generated by VB Migration Partner, you might see one or more of the following warnings:

Could not load file or assembly '<AssemblyName>, Version=…, Culture=neutral, PublicKeyToken=…' or one of its dependencies.
The system cannot find the file specified. while compiling method

You can safely ignore this warnings, because they are related to assemblies referenced by the CodeArchitects.VBLibrary.dll assembly but not actually used by your migrated project. NGEN is able to correctly optimize your application even if you read these warnings.

You can easily avoid these warnings, though. Just copy the following DLLs from VB Migration Partner’s setup folder to the directory where the compiled .NET application resides:

INetCtlsObjects.dll, MSCommLib.dll, MSMAPI.dll, MSScriptControl.dll, RDO.dll

Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers