Reflection can access methods, properties and other objects outside of the application domain. The Reflection Overview in VSHELP provides a good list of potential uses as well as definitions for application domains, assemblies, modules, etc.
I had a piece of code in a usercontrol today which could have been called by either a web page or another usercontrol. If I've referred to a usercontrol type with reflection before I've forgotten it, so today's reflection tidbit seemed like the first time, and first time events get a blog plug.
Here's the essence of the thing. Seems obvious to Reflector Heads out there, but I like the natural extensionality of Reflection to get a type via a Page.FindControl() as well as the Parent.Page.
if (_ProjCoType != ProjCoType.Sales) //ProjCoType enumerator determines the parent
{
Type parentType = this.Parent.Page.FindControl("uc_mycontrol").GetType();
parentType.InvokeMember("MyMethodInAUserControl",System.Reflection.BindingFlags.InvokeMethod, null, this.Parent.Page.FindControl("uc_mycontrol"),
new object[] {newid, _ProjCoType});
}
else
{
Type parentType = this.Parent.Page.GetType();
parentType.InvokeMember("MyMethodInAPage",System.Reflection.BindingFlags.InvokeMethod, null, this.Parent.Page, new object[] {newid});
}
A VSHELP bittie on Type:
Type is the root of the System.Reflection functionality and is the primary way to access metadata. Use the members of Type to get information about a type declaration, such as the constructors, methods, fields, properties, and events of a class, as well as the module and the assembly in which the class is deployed.