.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Fusion of assembly example

Posted By:Jean Paul       Posted Date: September 30, 2010    Points: 10    Category: Javascript    URL: http://www.dotnetspark.com  

This example shows how to load an assembly dynamically into the current domain and invoke a method.

// Create a ClassLibrary project and add the following class into it
// Add reference to System.Windows.Forms too
// Copy the dll to folder c:\temp

    public class Utility
        public void ShowMessage()
            MessageBox.Show("Hello from Utility!");

// Create a new Windows Application and add the following code to the form load event

            Assembly assembly = Assembly.LoadFile(@"c:\temp\ClassLibrary1.dll");
            Type type = assembly.GetType("ClassLibrary1.Utility");

            if (type != null)
                object instance = Activator.CreateInstance(type);
                type.GetMethod("ShowMessage").Invoke(instance, null);
                MessageBox.Show("Unable to find type!");


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend