Hi All,
I am facing a problem while loading the type from the referenced assembly.
I am implementing the Dependency Injection Design Pattern in the application. Here is the code
1) I have the ITest.cs - ITest<T>
2) A Container to create the ITest reference. The container holds a static method that returns ITest<T>
3) The consumer is as -
Test.dll is the assembly getting referenced and pertains the type ClassTest.
Please guide if anybody have suggestion on.
I am facing a problem while loading the type from the referenced assembly.
I am implementing the Dependency Injection Design Pattern in the application. Here is the code
1) I have the ITest.cs - ITest<T>
Code:
interface ITest<T> { //CRUD void Create(); void Insert(T t); void Update(T t); void Delete(T t); void Save(); }
Code:
public class Repository { public static ITest<T> GetInterfaceRepository<T>(string dll,string type) { try { var i = Activator.CreateInstance(dll, type) as ObjectHandle; //Here it is Giving an error as //Could not load type 'ClassTest' from assembly 'Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. var retval = i.Unwrap() as ITest<T>; return retval; } catch (Exception E) { throw E; } } }
Code:
ITest<ClassTest> iRepos = Repository.GetInterfaceRepository<ClassTest>("dllPathFor_ClassTest", "ClassTest"); iRepos.Create();
Please guide if anybody have suggestion on.