Reputation: 4477
We have a web service written in C# hosted under IIS. We're using AppDomains to separate invocations of a task - each invocation is run in a separate domain. The code does something like the following:
public class Simplified
{
public void Run()
{
AppDomain workDomain = AppDomain.CreateDomain(...);
var workUnit = (IWorkUnit)workDomain.CreateInstanceAndUnwrap(...);
workUnit.Execute(...);
//Done - but keep the workUnit around in case we need it again
}
}
However, each AppDomain
is loading separate copies of our dlls - which accounts for a large chunk of processing time. I understand you can somehow make assemblies load domain neutral so that they are shared across all appdomains. How do I do this for our IIS web service?
Upvotes: 1
Views: 662
Reputation: 4477
Turns out it's as simple as setting
setup.LoaderOptimization = LoaderOptimization.MultiDomain;
on the AppDomainSetup object used to create the domain. This works fine under IIS
Upvotes: 1