Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6601455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:45:17+00:00 2026-05-25T18:45:17+00:00

I am working on a way for my ASP.NET C# application to allow plugins

  • 0

I am working on a way for my ASP.NET C# application to allow plugins without recompiling the host application when new plugins are installed.

Here’s my plugin loader class (based on tutorials found online.)

public class PluginLoader
{
    public static IList<IPlugin> Load(string folder)
    {
        IList<IPlugin> plugins = new List<IPlugin>();

        // Get files in folder
        string[] files = Directory.GetFiles(folder, "*.plug.dll");
        foreach(string file in files)
        {
            Assembly assembly = Assembly.LoadFile(file);
            var types = assembly.GetExportedTypes();
            foreach (Type type in types)
            {
                if (type.GetInterfaces().Contains(typeof(IPlugin)))
                {
                    object instance = Activator.CreateInstance(type);
                    plugins.Add(instance as IPlugin);
                }
            }
        }
        return plugins;
    }
}

The concept is to create a IPlugin interface in the host application that new plugins can use. The loader then searches through the available DLLs and finds the classes that are of the IPlugin type. then those get instantiated and my host application can use them how it sees fit.

For example it could do this:

protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();
        string folder = Server.MapPath("~/bin/");
        path.Text = folder;

        var plugins = PluginLoader.Load(folder);
        if (plugins.Count == 0)
            sb.Append("No plugins found");
        else
        {
            sb.Append("<ul>");
            foreach (var plug in plugins)
            {

                sb.AppendFormat("<li>Default: {0}</li>", plug.Label);
                plug.SetLabel("Overwrote default label.");
                sb.AppendFormat("<li>New: {0}</li>", plug.Label);
            }
            sb.Append("</ul>");
        }

        message.Text = sb.ToString();
    }

Is this structure what IoC or DI is? The plugin is referencing the host, rather than the other way around. This seems to be consistent with the Inversion Of Control concept. Is there a fundamental difference between this code and IoC/DI?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:45:17+00:00Added an answer on May 25, 2026 at 6:45 pm

    This looks like a plugin architecture that utilises Inversion of Control, but not using Dependency Injection. It appears to be similar to the way MEF works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on my first asp.net/web development application. Obviously, I'm very new to asp.net
This is the scenario: I'm working on a new ASP.NET application that uses master
I am using a plugin system on an ASP.NET MVC application I am working
I'm working my way through some ASP.NET MVC reading and I have a web
Is there a way with ASP.NET to tell a data repeater which is working
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I'm working with an asp.net application that stores most data in a database and
I've been working on a C# ASP.Net application that requires images to be customized
I'm trying to extend the functionality of an ASP.net application that I'm working with.
I'm working on multilingual Asp.NET MVC application. In url i need to use category

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.