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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:45:39+00:00 2026-05-28T02:45:39+00:00

The problem I am having is that I would like to call a method

  • 0

The problem I am having is that I would like to call a method from a string. Here is what I am doing:

Building My List of Strings (Methods) there are three different checkboxList objects in my UI

private List<string> MyTest = new List<string>();
private void AddSelectedMethods()
{
        foreach(XName item in BaseTestList.CheckedItems)
        {
            MyTests.Add(item.ToString());
        }
        foreach (XName item in AdminTestList.CheckedItems)
        {
            MyTests.Add(item.ToString());
        }
        foreach (XName item in SubscriberTestList.CheckedItems)
        {
            MyTests.Add(item.ToString());
        }
}

Here is the Caller. If I take out the Reflections call and reference the method directly everything works but I don’t want to get into crating a huge list of if else statements.

    private void StartSiteTest(object sender, DoWorkEventArgs e)
    {
        if (!BackWorker1.CancellationPending)
        {
            if (SiteToTest == "estatesales.vintagesoftware.local" || SiteToTest == "localhost")
            {
                es = new EstateSaleTests(site, Sites.First(i => i.SiteUrl == SiteToTest), BasePath, SiteToTest, UseCurrentCompanies);
                foreach (string test in MyTests)
                {

                    // <<<!!!!!!!!  ------ The next line returns null ------ !!!!!!!>>>
                    MethodInfo thisMethod = es.GetType().GetMethod(test);

                    thisMethod.Invoke(es, null);
                }
            }
        }
    }

Any help on what I am doing wrong would be greatly appreciated.

!!!—– EDIT —–!!!

I’m an idiot. I had the class set to the list of strings but I forgot to rename my Methods Sorry about that. Yes the Methods were public and they are accessible I just have to rename them to the correct names now.

  • 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-28T02:45:40+00:00Added an answer on May 28, 2026 at 2:45 am

    The call you use seems pretty acceptable, imo.
    The thing is that GetType().GetMethod() is able to recover only public methods.

    See this MSDN link.

    In order to access methods with different acessors use this GetMethod(string, BindingFlags) overload.

    Hope this helps.

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

Sidebar

Related Questions

My problem here is that I would like to pass an object to a
HI Guys, Here I am having problem that How can I post an image
Problem I would like to trace the Uri that will be generated by a
I have a recursive method call. When any exception is thrown, I would like
In Rails 3, I am having a problem accessing a helper method from within
I have started having problems with my VPS in the way that it would
I am having problem that when i am trying to submit the form by
Hi The problem am having is that I have multiple TreeView control and each
The problem i'm having is that i've created a web service, and a windows
I'm trying to debug a cons script, and the problem I'm having is that

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.