I have a control engine that processes jobs. Each job configuration specifies which assembly and class it needs to find the jobs Run interface in. This assembly could be local or it could be on another server.
Eg I could have the following which all implement the Run interface
\Server1\Assembly1.Class1 \Server2\Folder1\Assembly2.Class2 \Server3\Folder2\Folder3\Assembly3.Class3
I want to be able to configure three jobs, each one referencing the relevant path and assembly name that It should run. The control engine then uses reflection to load the specified assembly above and runs the Run() method.
However the difficulty I have is that if the Assembly I am loading has dependencies, they are not loaded. Eg if Assembly1 depends on Entity Framework and the control engine doesn't have that as a dependency, it will fail. Entity Framework will of course be present in the same folder as \Server1\Assembly1.Class1 for example as Class1 depends on it and so it builds it to that location, but the Control engine only knows to load Class1, not EF.
I need a way to specify for each job, which dependent assemblies are required to also load and then the best way to load them from the same location as the Run() interface Assembly class.
I have looked at AppDomain.AssemblyResolve and thought about using a custom attribute and reflection but I feel like I haven't cottoned on to the best design to do this as it feels hacky.
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire