creating/compiling objects dynamically

This is not necessary for web applications, only for web sites
since in a web application you can access a class definition via the namespace and simply instanciate a new instance.

string pageToLoad = “~/PageXXX.aspx”; 
Type type = BuildManager.GetCompiledType(pageToLoad);

Page LoadedPage = (Page)Activator.CreateInstance(type);


or ((IHttpHandler)Page).ProcessRequest(HttpContext.Current);

Now you can for instance access controls on the page:
(Control control in LoadedPage.Controls)

now use reflection to get hold of properties and methods.
System.Reflection.MethodInfo info = type.GetMethod(“BuyTicket”); 

object data = info.Invoke(obj, null);


What's your thoughts on this?


Protected by WP Anti Spam