mercredi 8 mars 2017

Fail to load an assembly C#

I have an assembly called Lab that is built by a project that is part of a solution. This assembly contains an object that I want to access using reflection from a different assembly on the same solution. In the other assembly (Called BL) I have the following code:

Assembly assembly = Assembly.Load("Lab");

The problem is, that it is throwing FileNotFoundException unless I add a row that tries to initiate an object from the Lab assembly anywhere in the code. As if the compiler loads the Lab assembly to a recognisable place for the Assembly.Load function.

This really confuses me, I tried passing the full assembly name And also tried to pass the assembly's absolute path to Assembly.LoadFrom but to no avail, same problem in all cases.

The reason I am trying to access the object trough reflection rather than just referencing to it is because the code is part of a module that will be isolated. And then the reflected dll (in this case Lab.dll) will be passed dynamically during runtime.





Aucun commentaire:

Enregistrer un commentaire