Loading .NET Assemblies


The System.Reflection.Assembly class represents a physical .NET executable, either an .exe or a .dll file. The System.Reflection.Assembly class can be used to load assemblies, load modules, or discover a type from the assembly and create an instance of it. The Assembly class does not have a public constructor, so in order to get a reference to an Assembly instance, you must use a static method on the Assembly class itself. The static method LoadFrom loads an assembly given its filename. This method loads the assembly into the AppDomain of the caller and returns an Assembly instance that represents the loaded assembly. Listing 13.1 demonstrates how to load an assembly by using the LoadFrom method.

Listing 13.1
 C# Assembly anAssembly = Assembly.LoadFrom("\sample.dll"); MessageBox.Show("Loaded " + anAssembly.FullName); VB Dim anAssembly as Assembly.LoadFrom("\sample.dll") MessageBox.Show("Loaded " & anAssembly.FullName) 


Microsoft.NET Compact Framework Kick Start
Microsoft .NET Compact Framework Kick Start
ISBN: 0672325705
EAN: 2147483647
Year: 2003
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net