Reputation: 1
I have a Windows service used for deploying dacpac's. The service has no other references other those required for it to be installed and run. It only loads in a different AppDomain an assembly which does all the work. The new domain has shadowCopy set to true and all the required references are loaded in the cache folder. The problem occurs after the deploy method of DacServices has run to completion.
var service = new DacServices(connectionString.ConnectionString);
//after this method exists, Microsoft.Data.Tools.Schema.Sql.dll is loaded in the parent domain
service.Deploy(package, connectionString.InitialCatalog, true, options);
Just before the methods completes, Microsoft.Data.Tools.Schema.Sql.DLL
is loaded in the parent domain and not from the cache folder but from the app base directory (see Loaded modules). It doesn’t matter if the method runs successfully or it throws an exception.
Is there any way to find out why is the DLL loaded or why isn’t loaded from the cache folder?
This is the code for loading the worker assembly
var domaininfo = new AppDomainSetup
{
ApplicationBase = executingPath,
ShadowCopyFiles = "true",
CachePath = $@"{executingPath}\Cache",
ApplicationName = "DbUpdater",
LoaderOptimization = LoaderOptimization.MultiDomain,
};
var updater = Path.Combine(executingPath, "DbUpdater.exe");
_domain = AppDomain.CreateDomain("DbUpdaterDomain", AppDomain.CurrentDomain.Evidence, domaininfo);
_domain.ExecuteAssembly(updater);
Upvotes: 0
Views: 90