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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:48:35+00:00 2026-05-23T12:48:35+00:00

so what i am tryng to do is to run the InvokeMember in a

  • 0

so what i am tryng to do is to run the InvokeMember in a thread. Got the info here how to do it: C# : Invoke a method with [Type].InvokeMember() in a separate Thread

So my code looks like this right now and this works:

            Assembly OCA = Assembly.LoadFrom("./CardMax2.Elkart.OrderClutchAgent.dll");
            Type[] types = OCA.GetTypes();
            foreach (var type in types)
            {
                //MethodInfo[] methods = type.GetMethods();
                if (type.Name == "OrderClutchAgent")
                {
                    var obj = Activator.CreateInstance(type);
                    type.InvokeMember("RunAgent",BindingFlags.Default | BindingFlags.InvokeMethod,null,obj,null);
                }

            }

Now when i try to run it in a thread, the code looks like this:

            Assembly OCA = Assembly.LoadFrom("./CardMax2.Elkart.OrderClutchAgent.dll");
            Type[] types = OCA.GetTypes();
            foreach (var type in types)
            {
                //MethodInfo[] methods = type.GetMethods();
                if (type.Name == "OrderClutchAgent")
                {
                    var obj = Activator.CreateInstance(type);
                    Thread t = new Thread(delegate()
                                              {
                                                  type.InvokeMember("RunAgent", BindingFlags.Default | BindingFlags.InvokeMethod, null, obj, null);
                                              });
                    t.Start();
                }

            }

But with this code i am getting strange exception:

Method 'Org.BouncyCastle.Asn1.X509.TbsCertificateList+RevokedCertificatesEnumeration+RevokedCertificatesEnumerator.RunAgent' not found.

Am i doing something totally wrong or maybe someone can point out why i am getting this exception..

  • 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-23T12:48:35+00:00Added an answer on May 23, 2026 at 12:48 pm

    the legendary foreach capture issue – by the time it gets around to invoking it (on a different thread), the type variable refers to a different Type…

    Make a copy instead:

    foreach (var tmp in types)
    {
        var type = tmp;
        // your code
    }
    

    The difference is that the loop variable (type in your example, tmp in mine) is scoped outside the loop (according to the spec), hence for capture purposes it is a single variable common to the entire loop. However, type in my example is scoped inside the loop, so (for capture purposes) is treated as a different variable per iteration.

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

Sidebar

Related Questions

When I'm trying run below code in Oracle 11g , @?/rdbms/admin/prvtmail.plb I got this
Trying to run z3c.form.testing based code on Plone 4.1 and getting this exception Traceback
When trying run this code: At first it prints Process some_id BEFORE enter for
Trying to run Nunit tests parameterized with TestCase attribute. Something like this: [TestFixture] public
Am trying to run this baseline unit test from Powermock. Running the code As-Is
Im trying to run something like this: <a href=login.php?logout=1 id=logout>logout</a> <div id=main> <?php require_once('getPhotos.php')
Im trying to run this code . Basically I want the https://admin:qwerty123@ '$dmp':7777/set_param?'$params command
Im trying to run exe file with c++ with no luck I tried this:
I'm tryng to write a simple Java program that runs some code every hour
I wrote this C program for Win32/c compiler but while i'm trying run this

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.