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

  • SEARCH
  • Home
  • 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 6737425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:14:51+00:00 2026-05-26T11:14:51+00:00

I followed an tutorial how to make application support plugins. Everything seems to be

  • 0

I followed an tutorial how to make application support plugins. Everything seems to be working fine, but I need the plugin to be able to call functions and access variables in main application, not just the other way around. I have an http wrapper class that will monitor net usage etc.. for the main app. The plugin would call http wrapper from the mother application.

How can I accomplish this? Do I need to define a class with all the available functions/variables? I will also need the plugin to generate GUI, so that user can set some settings for it.

This is what I got so far:

Main Application:

namespace MainApplication
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        List<iPlugin> PLUGIN_LIST = new List<iPlugin>();

        public void LoadPlugins()
        {
            // load plugins..
        }

        // how do I call this function from a plugin?!
        public void HTTP()
        {
            // do some networking stuff..
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LoadPlugins();
        }


    }
}

Plugin Interface:

namespace PluginInterface
{
    public interface iPlugin
    {
        string GetPluginName();

        void callHTTP();

        void SerVar(string var);
    }
}

The Plugin:

namespace MyPlugin
{
    public class Main : iPlugin
    {
        string variable = "";

        public string GetPluginName()
        {
            return "MyPlugin";
        }

        public void callHTTP(){
            MainApplication.HTTP(); // call HTTP in main application
        }

        public void SerVar(string var)
        {
            variable = var;
        }
    }
}

Also, when I followed the tutorial, plugin interface was a seperate project, which I had to ‘add as reference’ in both MainApplication and myPlugin. Does that mean that my application and plugin are dependent on pluginInterface.dll? or it is just needed for development? if they’re depended in runtime, how can I define it in both, my app and plugin, so that I don’t have to use extra dll? Hope that makes sense, Thanks!

EDIT: Full MainApplication code

public interface iPlugin
{
    string GetPluginName();

    string GetInformation();

    void SerVar(string var);
}


namespace MainApplication
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        List<iPlugin> PLUGIN_LIST = new List<iPlugin>();

        public void LoadPlugins()
        {

            string path = Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
            string pluginDir = Path.GetDirectoryName(path) + "\\Plugins";

            foreach (string s in Directory.GetFiles(pluginDir, "*.dll"))
            {
                // THIS LINE GIVES THE ERROR
                Type[] pluginTypes = Assembly.LoadFile(s).GetTypes();

                foreach (Type t in pluginTypes)
                {
                    if (t.ToString().Contains("Main"))
                    {
                        iPlugin plugin = Activator.CreateInstance(t) as iPlugin;

                        PLUGIN_LIST.Add(plugin);
                        break;
                    }
                }
            }

        }



        private void Form1_Load(object sender, EventArgs e)
        {
            LoadPlugins();
        }

    }
}
  • 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-26T11:14:51+00:00Added an answer on May 26, 2026 at 11:14 am

    One approach you could take is to define an interface that contains all the methods that you would like to call from the mother application (called say IMother), and make the mother application implement this.

    Then you could update IPlugin to have a method like void SetMother( IMother mother ) and when you load each plugin you could call this method on the plugin. That way each plugin would have the IMother reference from the beginning and could call methods as necessary.

    Regarding your question on plugininterface.dll, yes, both MainApplication and myPlugin are dependent on that dll (it is not just needed for development). If you want to avoid using an extra dll (having references to extra dlls isn’t generally an issue) I would put the plugin interface in the same project as MainApplication. I’m not sure if I’m understanding your layout though, so if that doesn’t answer your question please add more details as to how your projects/solution is configured.

    EDIT BASED ON COMMENT:

    I assume your layout is something like the following:
    One solution file that contains three projects
    One project for MainApplication
    One project for myPlugin
    One project for the plugin interface.

    You could move the code files for the plugin interface into the MainApplication project. That way MainApplication would not be dependent on anything else. Just take the .cs file from the plugin interface project and add it to MainApplication. You would then need to reference MainApplication from myPlugin, but that should be ok.

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

Sidebar

Related Questions

I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/ , but no matter what I do, and what
I followed several tutorial to make this work, but I can't get draggable items.
I have followed many a tutorial to make sure that this is correct but
I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I
I am working on Windows Azure. I followed some tutorial about how to store
I followed the RailsCasts tutorial to do a simple search with autocomplete, but it
I've followed the tutorial from here: Twitter Client Tutorial to make a little twitter
I followed the tutorial described here , in order to make the TinyMCE Spellchecker
I followed the tutorial at http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module step by step to make my module install
The plugin has to call functions in an external dependent dll file. I followed

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.