Wow! Writing client script with code is not uncommon, but now you can write compiled code that runs on the serverand that interacts with the same code that creates it. Is that cool, or what? Let us know in the csharp.general discussion group.
Use the System.Reflection classes in the .NET Framework to write, execute, and interact with code you write dynamically at run-time from your applications.
by Randy Holloway
October 21, 2002
What You Need
To build the samples you need Visual Studio .NET and the .NET Framework (sp1). You should have an understanding of the .NET Framework and scripting on the Windows platform.
Reflection is a powerful tool in the .NET Framework that enables type discovery, the viewing of assembly metadata, and dynamic invocation of assembly code at runtime. You can also use reflection to create object instances from types at runtime using the System.Reflection.Emit namespace. Typically, you'd use these features for creating compilers, and building development tools for evaluating compiled codebut you can also use them for generating and processing scripts.
With the dynamic invocation functions available through reflection, you can create a reference to an assembly at runtime, determine what methods of that assembly are available, and to execute one of these methods. This can be very useful for late binding and for working with assembly code from third parties where different assembly versions expose different classes and methods, yet the management of that code is not under your control. But you can also use these techniques to support script creation by users or for referencing components that may not be available at compile time. In addition, this is a useful technique for executing code generated dynamically at runtime.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!