TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Wes
NA
5
0
Dynamic Assembly Loading
Apr 18 2008 10:21 AM
I'm trying to extend my CMS with a plugin interface to make extensibility a little easier to manage. I created 2 classes: an abstract base class (baseModule) containing a single abstract method Init() and a class that inherits from it (TestModule) and throws an exception when Init is called. In my Engine, I'm doing the following:
if (!module_dir.Exists) throw new Exception("Modules directory does not exist.");
foreach (FileInfo f in module_dir.GetFiles("*.dll"))
{
Type t = Assembly.LoadFile(f.FullName).GetType();
baseModule m = Activator.CreateInstance(t) as baseModule;
if (m == null)
{
throw new Exception("dll is not of type IModule");
}
module_list.Add(m);
}
Unfortunately when I hit Activator.CreateInstance, I get the error :
"No parameterless constructor defined for this object."
Any ideas what I'm doing wrong?
Reply
Answers (
5
)
Integrated Windows Authentication in ASP.NET
DateTime Format