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>
Expand|Select|Wrap|Line Numbers
- interface ITest<T>
- {
- //CRUD
- void Create();
- void Insert(T t);
- void Update(T t);
- void Delete(T t);
- void Save();
- }
Expand|Select|Wrap|Line Numbers
- 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;
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- ITest<ClassTest> iRepos = Repository.GetInterfaceRepository<ClassTest>("dllPathFor_ClassTest", "ClassTest");
- iRepos.Create();
Please guide if anybody have suggestion on.