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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:12:10+00:00 2026-05-20T12:12:10+00:00

I have been able to successfully execute other methods using reflection but I am

  • 0

I have been able to successfully execute other methods using reflection but I am now getting a TargetInvocationException. Although the TargetInvoationException points me to the methodInfo.Invoke method, stepping through the code shows the exception occuring in the Load method when SampleXMLToDataTable is called. The SampleXMLToDataTable is a public static method in the same class as Load. The error is thrown as the code is attempting to enter the SampleXMLToDataTable.

Is there a problem calling methods from within other methods that are being called using reflection?

The code that calls via reflection:

 private Object CreateXMLDataLoaderInstance(string xml)
 {
  object o = null;

  Assembly demandAssembly = LoadSampleDemandAssembly();
  Type assemblyType = demandAssembly.GetType("SampleDemand.XMLDataLoader");
  MethodInfo methodInfo = assemblyType.GetMethod("Load");
  o = Activator.CreateInstance(assemblyType, new Object[1] { true });

  Object[] oParamArray2 = new Object[1];

  methodInfo.Invoke(o, new Object[1] { xml });//TargetInvocationException

  return o;
 }

And the method it is trying to invoke:

 public void Load(string xml)
{
  XmlDocument xDoc = new XmlDocument();
  xDoc.LoadXml(xml);

  XmlNode settingsNode = null;
  foreach (XmlNode xNode in xDoc.FirstChild.ChildNodes)
  {
    string name = xNode.Name;
    string wsx = xNode.ChildNodes[0].OuterXml;

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(wsx);
    DataTable dt = SampleXMLToDataTable(doc);//Where the code breaks
    XMLSample xmlWS = new XMLSample(dt, wsx, name);

    this.sample.Add(name, xmlWS);
  }
  if (settingsNode != null)
  {
    settings = GetSettings(settingsNode);
  }
}
  • 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-20T12:12:11+00:00Added an answer on May 20, 2026 at 12:12 pm

    Your error just means that an exception is being thrown somewhere in the invoked method. This is exactly what you have pointed out. Your SampleXMLToDataTable method is throwing an exception. This has nothing to do with calling it via reflection. I suspect that if you call it directly, you will get an exception in the exact same spot.

    This is not a limitation of reflection, you just get a different exception because you are invoking it through reflection, though the inner exception of the TargetInvocationException should give you more information.

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

Sidebar

Related Questions

I have started using https://github.com/omab/django-social-auth and been successfully able to login via twitter, google
I have been able to successfully implement Shared Preferences into my application but I
I have been able to successfully get an access token from Vimeo using the
I have successfully created a custom Facebook open graph action, and have been able
I've been able to have JPA/Hibernate to replicate the ON DELETE CASCADE functionality successfully
Hi I have been able to extract a VARCHAR to a date using string_to_date
I am pretty new to GraniteDS..So far I have been able to successfully configure
I'm writing an import from CSV and have been able to successfully manually set
Based on several good articles I have been able to successfully create a few
I have a problem I haven't been able to solve in 2 days now,

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.