Question

I need to create multiple AppDomains in my .NET in-process COM server (it's a Windows Explorer namespace extension).

In my test Console Application, i am able to create 10 domains + WPF windows in 40 seconds, which is unacceptable. Adding LoaderOptimization.MultiDomainHost speeds this up to 2-5 seconds, which is OK.

However, there is no Main method in a COM server, and specifying LoaderOptimization in AppDomainSetup only affects loading 2 or more additional domains (i.e. first additional AppDomain starts 3-4 seconds, others in 0.1-0.3 sec)

So, Can I specify LoaderOptimization for an in-process COM server, and if yes, how?

Was it helpful?

Solution

You cannot get this option set as long as you write your code in C#. You'd need to host the CLR yourself so you can configure the appdomain and that requires C++ code. The core MSDN library article set starts here.

Trying to figure out why it takes so dang long ought to produce some results. It certainly doesn't sound like a cold start problem, associated with the cost of finding the assemblies on disk for the first time. That perf hit is only relevant on the very first appdomain, later ones should be quick since they'll find the assemblies in the file system cache.

Which leaves a warm start problem, associated with just-in-time compiling the IL to machine code. The quick fix for this is running ngen.exe on your assembly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top