[SOLVED] Activator.CreateInstance Performance Alternative

Issue

I’m using RedGate to do some performance evaluation. I notice dynamically creating an instance using Activator.CreateInstance (with two constructor parameters) is taking a decent amount of time… is there a better alternative that still utilizes a reflective approach (not explicit instantiation)?

Solution

Use a compiled lambda if you can, its MUCH faster.

https://vagifabilov.wordpress.com/2010/04/02/dont-use-activator-createinstance-or-constructorinfo-invoke-use-compiled-lambda-expressions/

Answered By – poindexter12

Answer Checked By – Jay B. (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *