-
Notifications
You must be signed in to change notification settings - Fork 4
Assembly Loading
It is important to understand how the Shift server loads the client assemblies to avoid exception errors when running jobs. All running jobs will be under the domain of the Shift server app, whether it's an Azure WebJob, Windows service, ASP.NET or other .NET apps. To run the jobs successfully, all dependencies must be loaded in the running process. Shift server apps can directly reference dependencies before compile time or use the AssemblyFolder
and AssemblyFilePath
settings.
It is much easier and preferred to use the AssemblyFolder
setting to load all dependencies. When Shift server starts, it attempts to load all *.DLL from the AssemblyFolder
location. Any update to the assemblies will simply allow dropping in new assemblies and then restarting the server app without recompiling the server app.
For more granular control of assembly loading, use the AssemblyFilePath
setting. It is best to use a sub folder under the server executable and to use relative path for path locations. However, a mix use of absolute or relative path is allowed in the same assembly list file.
When using relative path, the base directory is always the server app domain starting executable location, which is returned by the .NET AppDomain.CurrentDomain.BaseDirectory
. This is different than the System.Environment.CurrentDirectory
, which will return C:\Windows\system32 for Windows services, not the base location of the running Shift.WinService.exe file.
For example: Executable job server is in C:\Shift\Shift.Demo.Server.exe. Client DLLs are in sub folder C:\Shift\client-assemblies. The base directory is always starting at: C:\Shift\
Various possible path usage examples in assembly list text file with C:\Shift\ as base location:
In File | Server Conversion |
---|---|
client-assemblies\Shift.Demo.Jobs.dll | C:\Shift\client-assemblies\Shift.Demo.Jobs.dll |
Shift.Demo.Jobs.dll | C:\Shift\Shift.Demo.Jobs.dll |
C:\Shift\client-assemblies\Shift.Demo.Jobs.dll | C:\Shift\client-assemblies\Shift.Demo.Jobs.dll |
\client-assemblies\Shift.Demo.Jobs.dll | C:\client-assemblies\Shift.Demo.Jobs.dll |
..\Shift.Demo.Jobs.dll | C:\Shift.Demo.Jobs.dll |