I am developing an application that automatically generates assemblies using the CSharpCodeProvider (.Net Framework 3.5). These assemblies contain a single class with a very large number of local variables and methods. After compilation
I create an instance of this class (using Activator.CreateInstance) to be used elsewhere in the application. When the application is deployed on a 32-bit system (tested on Win 7 Prof 32-bit and on Win XP) the CreateInstance method returns after
1 or 2 seconds, i.e. it first JITs the assembly before creating the instance. However, on a 64-bit system (tested on Win 7 Home 64-bit, Win Server 2003 64-bit and Win Server 2008 64-bit) CreateInstance takes up to 5 minutes to return.
Is there any reason why it would be that much slower on a 64-bit machine?
I have tried many different options when compiling, such as setting the platform to x64, using the /optimize flag, etc, but none of these have made a difference.
I also tried calling PrepareMethod on all the method in the class. When I do this in the 32-bit environment, it takes approximately 10 seconds. In the 64-bit environment it takes more than 3 minutes.
As a last resort I tried ngen before constructing the object, but this made no difference in the execution time.
View Complete Post