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 6779199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:21:25+00:00 2026-05-26T16:21:25+00:00

I have a single plugin, that takes value for an input and returns the

  • 0

I have a single plugin, that takes value for an input and returns the result. I’m loading it like this:

public void load_modules()
{
    string path = Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
    string pluginDir = Path.GetDirectoryName(path) + "\\Modules";

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

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


                GLOBAL_VARIABLES.MODULES.Add(module);

                break;
            }
        }
    }

}

Here is the code I’m using to execute plugin:

 List<MY_API> plugin_instances  = new List<MY_API>(); // define container of the instances
 for(int i=0; i<10; i++){
     plugin_instances.add(GLOBAL_VARIABLES.MODULES[0]); // loaded module from load_modules()

     MessageBox.show(plugin_instances.exec(i)); // execute plugin
 }

And I have a timer to monitor to minor status of the first loaded module.

label1.text = GLOBAL_VARIABLES.MODULES[0].getStatus();

The getStatus() function displays what variable is passed to plugin’s exec() function.

The problem is
I didn’t execute the *GLOBAL_VARIABLES.MODULES[0]*, I only used it to make copies off of it. I executed all plugins in *plugin_instances* list, which should contain 10 copies of *GLOBAL_VARIABLES.MODULES[0]*.

To my surprise GLOBAL_VARIABLES.MODULES[0] gets executed, even though it shouldn’t, I can see that on label1. Instead of executing 10 instances of my plugin, the GLOBAL_VARIABLES.MODULES[0] gets executed 10 times.

Seems like plugin_instances.exec(i) acts like a reference to GLOBAL_VARIABLES.MODULES[0], instead of individual copy of GLOBAL_VARIABLES.MODULES[0].

How can I get each instance individual, not as reference? Thanks!

  • 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-26T16:21:25+00:00Added an answer on May 26, 2026 at 4:21 pm

    Update to reflect question modification:

    You need to create a new instance of the module type for each one that you want to execute. You may need to clean the following code up, but it gives you the idea:

     plugin_instances.add(Activator.CreateInstance(GLOBAL_VARIABLES.MODULES[0].GetType()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single user java program that I would like to have store
I have made a jQuery plugin that works fine when applied to a single
I have a single wordpress plugin in my site, that in general is free.
I am creating my first plugin and have a single function that controls the
I have a makefile template to compile a single DLL (for a plugin system).
I have a feature called foo, plugin called foo, and a single fragment foo.win32.x86.
I have an single threaded, embedded application that allocates and deallocates lots and lots
I have a single line CEikLabel in my application that needs to scroll text.
I have a single spool mbox file that was created with evolution, containing a
I have a single windows shell command I'd like to run (via EXEC master..xp_cmdshell)

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.