This is a mirror of official site: http://jasper-net.blogspot.com/

Loading an assembly using Reflection and invoking static methods from it

| Sunday, May 16, 2010
In this article, I will show how to load an assembly at runtime using Reflection and to invoke static methods from it.

Background

Reflection is Microsoft's extra-ordinary feature. Before we begin, we must know some very important concepts about assemblies. Assemblies are the building blocks of .NET Framework. An assembly is a collection of types and resources that are built to work together, and form a logical unit of functionality.

An assembly contains modules, modules contain types, and types contain members. Using Reflection, we can create an instance of a type, can invoke a type's methods, or access its fields and properties. For this tutorial, the above statement is enough. For a detailed information, click here.

Using the code

This tutorial consists of two projects:

Utllity (the Class Library)
LoadAssembly (application that will load Utility using Reflection)
The Utility Class Library consists of two methods:

Encrypt (takes a string as input and returns the encrypted string as output)
Decrypt (takes an encrypted string as input and returns the original string)
I will not discuss the utility code as it is not needed to.

Read more: Codeproject

Posted via email from jasper22's posterous

0 comments: