how are you??
I hope one of you can help me!!
These are the packages that come in play and their relation (I'm working with C#):
Web---->ILogic
^
|
Logic------>Ilog
^
|
Log
Let's suppose that in each project there's a class with the same name. The class Logic implements the ILogic interface, and the class Log implements the ILog interface.
So these would be the classes:
public class Web{
internal static readonly ILogic = InitializeLogic();
private static ILogic InitializeLogic(){
string path = ConfigurationManager.AppSettings["LogicAssemblyPath"];
string className = ConfigurationManager.AppSettings["LogicClass"];
Assembly assembly = Assembly.LoadFile(path);
Type type = assembly.GetType(className);
return (ILogic)Activator.CreateInstance(type, null);
}
}
public class Logic{
internal static readonly ILog = InitializeLog();
private static ILogic InitializeLogic(){
string path = ConfigurationManager.AppSettings["LogAssemblyPath"];
string className = ConfigurationManager.AppSettings["LogClass"];
Assembly assembly = Assembly.LoadFile(path);
Type type = assembly.GetType(className);
return (ILog)Activator.CreateInstance(type, null);
}
}
So, when I call
Web.Method();
It instantiates the Logic class using Reflection, which at the same time instantiates the Log class using Reflection again.
This throws the next exception:
System.IO.FileNotFoundException: Could not load file or assembly 'ILog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
This can be solved by adding a reference in Web either to ILogic or to ILog (if I add one of these references it WORKS, there are no problems with the paths in the appsetting or anything like that), but obviously, I need a solution where I don't need to add any reference.
Any help/insight will be appreciated!!
Thanks!