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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:22:30+00:00 2026-06-10T14:22:30+00:00

I want to modify the below code to be able to use a private

  • 0

I want to modify the below code to be able to use a private method

        //use reflection to Load the data
    var method =
                    typeof(MemberDataFactory)
                    .GetMethod("LoadData")
                    .MakeGenericMethod(new [] { data.GetType() })
                    .Invoke(this, null);

Ive tried the following with no luck:

        //use reflection to Load the data
    var method =
                    typeof(MemberDataFactory)
                    .GetMethod("LoadData")
                    .MakeGenericMethod(new [] { data.GetType() })
                    .Invoke(this, BindingFlags.Instance | BindingFlags.NonPublic, null , null, null);

Also what is “var” in terms of this code? Id prefer to specify its type instead of using var.

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-06-10T14:22:32+00:00Added an answer on June 10, 2026 at 2:22 pm

    You want to use this overload of Type.GetMethod(), which is where you pass your binding flags. The default .GetMethod(string) only looks for public methods, so it returns null, hence your null reference exception.

    Your code should be something more like:

    var method =
            typeof(MemberDataFactory)
            .GetMethod("LoadData", BindingFlags.Instance | BindingFlags.NonPublic) // binding flags go here
            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

below is the code which i want to modify $input = fopen(php://input, r); $temp
I want to modify the code snippet below in such a way, that I
I want to modify the below code to read the nodes from a text
I use below code to modify style of ListView item click. list_four_corner_selector.xml <?xml version=1.0
I want to modify some code in the Eclipse JDT itself (In the Debug
Overview I want to be able to modify request parameters and content to 3rd
I show ProgressDialog in AsyncTask method. My code as below: @Override protected void onPreExecute()
I use below code to open .doc file by call other application. But I
Question summary: How do I modify the code below so that untrusted, dynamically-loaded code
I use below code to get the bitmap of all sd card photo. String[]

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.