Loading Assemblies Dynamically with Load() and LoadWithPartialName() : Assembly « Development Class « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » Development Class » AssemblyScreenshots 
Loading Assemblies Dynamically with Load() and LoadWithPartialName()
Loading Assemblies Dynamically with Load() and LoadWithPartialName()


using System;
using System.Reflection;
using System.IO;
   
public class MainClass
{
    static void Main(string[] args)
    {
        AssemblyLoader("System.Xml, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"false);
        AssemblyLoader("System.Xml"false);
        AssemblyLoader("System.Drawing"true);
    }

    public static void AssemblyLoader(string LoadedAssemblyName, bool PartialName)
    {
        try
        {
            Assembly LoadedAssembly;
            Console.WriteLine("| Loading Assembly {0}", LoadedAssemblyName);
            if(PartialName == true)
                LoadedAssembly = Assembly.LoadWithPartialName(LoadedAssemblyName);
            else
                LoadedAssembly = Assembly.Load(LoadedAssemblyName);

            Console.WriteLine("Full Name: {0}", LoadedAssembly.FullName);
            Console.WriteLine("Location: {0}", LoadedAssembly.Location);
            Console.WriteLine("Code Base: {0}", LoadedAssembly.CodeBase);
            Console.WriteLine("Escaped Code Base: {0}", LoadedAssembly.EscapedCodeBase);
            Console.WriteLine("Loaded from GAC: {0}", LoadedAssembly.GlobalAssemblyCache);
        catch(FileNotFoundException) {
            Console.WriteLine("EXCEPTION: Cannot load assembly.");
        }
    }

}
           
       
Related examples in the same category
1. Create assemblyCreate assembly
2. Examining Location InformationExamining Location Information
3. Working with an Assembly Entry PointWorking with an Assembly Entry Point
4. Finding and Creating Assembly Types
5. Retrieving a List of Referenced Assemblies
6. Simple Windows Form Application with Version InformationSimple Windows Form Application with Version Information
7. Find Attribytes from assembly nameFind Attribytes from assembly name
8. Get current application domainGet current application domain
9. List All Types from an AssemblyList All Types from an Assembly
10. List All Members from an AssemblyList All Members from an Assembly
11. Use Assembly to indicate the version and cultureUse Assembly to indicate the version and culture
www___.__j__a_v___a__2s__.__com | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.