The problem and current solution
A business app needs to interface with a 3rd party app which provides external client data. The 3rd party API is through client-specific assemblies which are provided by the clients and stored locally. Across all clients the assemblies are known and have the same interface, but each client may have customizations that result in different data, so it's necessary to run the app in the context of each set of assemblies.
The current solution is to house each client's set of assemblies in their own folder with an IIS web app on top of it. The business app call a particular client IIS web app through a local web request, which loads in the client's assemblies:
This solution works, but is a lot of overhead to maintain on the server, and adds complexity to the application and deployment. There are hundreds of clients, and 1 IIS web app per client.
The Goal
I would like to get rid of the IIS web apps and just have the business app load a particular client's assemblies at runtime from their directory. Something like:
I have been looking into AppDomains, but it feels like that is not quite the right solution for this. There are 5-ish different request types that happen, and within each request, several API calls that are made to the client application. The API calls are a mix of instance and static methods, which has proven challenging to do with AppDomains.
Again, I don't know if this is possible, but it seems like I'm looking for something like:
OnAssemblyLoad(assemblyName =>
{
if(assemblyName.StartsWith("ClientAssembly"))
{
return "clients\clientA";
}
else
{
return "[executing directory]";
}
});
Or some way I can create a mapping for a set of assemblies. As an extra wrench, a set of the client assemblies are in the executing directory (for compile reference), so I'll need to ignore those and use the specific version from the other directory.
I hope I've explained the problem and desired solution well, but if anything is unclear please let me know, and thanks!