Dynamically Loading and calling a .net object

Posted on 2003-10-30
Last Modified: 2008-03-04
Is it possible to dynamically load then call a .net object. For instance, I have a exe and with this exe, I want to provide a folder that has a bunch of .net dlls with the same interface. I don't know the names of these dlls before the exe is compiled. I want to load all of the .net objects into memory and let the user select which ones to use.
Question by:skibud2
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 10

Assisted Solution

ptmcomp earned 125 total points
ID: 9654174
Yes, I've also done this already.
Just use:
Type myType = Type.GetType("Full.Class.Name, AssemblyName");

Author Comment

ID: 9654682
doesn't that assume that it is already loaded in the GAC? I am trying to load it from the dll.

Accepted Solution

etmendz earned 125 total points
ID: 9654996
Interesting project. ptmcomp's suggestion is close. You can read about the following and decide on what serves your purpose best:


Have fun...

Author Comment

ID: 9655198
I split it 125/125 because you both gave answers that helped me. Thanks guys!

LVL 10

Expert Comment

ID: 9656129
That's the code I used:
                  foreach (string typeName in typeNames)
                        Type type;
                        object dataSource;

                        type = Type.GetType(typeName);
                        if (type == null)
                              throw new ApplicationException(string.Format("Cannot load type '{0}'", typeName));
                        dataSource = Activator.CreateInstance(type);

This way there is no need to call Assembly.Load()

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Please explain purpose of GZIP 4 81
How can I do Unit Testing with Session ? 1 41
Connect Gridview column to Textbox in C# 2 54
C# Get Current Exchange Rate from XE 9 40
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question