How can I load a Class contained in a website from a DLL referenced by that website???
Posted
by Morgeh
on Stack Overflow
See other posts from Stack Overflow
or by Morgeh
Published on 2010-04-02T18:39:08Z
Indexed on
2010/04/02
18:43 UTC
Read the original article
Hit count: 396
Ok so this is alittle bit obscure and I'm not sure its the best way of doing what I'm trying to do but here goes.
Basically I have a Presentation Layer Dll in my web site which handles the Model View Presenter classes. The presentation layer also handles login for my website and then calls off to a web service. Currently whenever the presentation layer calls to a model it verifies the users details and if they are invalid it calls to a loginHandler which redirects the user to the login page. However I cannot dynamically load a new istance of the Login Page in my website from within my Presentation layer.
I've tried to use reflection to dynamically load the class but Since the method call is in the presentation assembly it is only looking within that assembly while the page I want to load is in the website.
heres the reflection code that loads the View:
public ILoginView LoadView()
{
string viewName = ConfigurationManager.AppSettings["LoginView"].ToString();
Type type = Type.GetType(viewName, true);
object newInstance = Activator.CreateInstance(type);
return newInstance as ILoginView;
}
Anyone got any suggestions on how to search within the website assembly? Ideal I don't want to tie this implementation into the website specifically as the presentation layer is also used in a WPF application.
© Stack Overflow or respective owner