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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:58:00+00:00 2026-06-16T06:58:00+00:00

I have two very simple methods, one of which I can invoke and the

  • 0

I have two very simple methods, one of which I can invoke and the other give me not found exception, here are the methods:

class SimClass
    {
        public int GeneralMethod1(int a)
        {
            return a;
        }

        public int GeneralMethod2(Input input)
        {
            return input.Numberi;
        }

    }
    class Input
    {
        public int Numberi { get; set; }
    }

I simply can invoke “GeneralMethod1”:

        Assembly assembly = Assembly.LoadFrom("C:\\Amir\\SimFIle.dll");
        Type type = assembly.GetType("SimFIle.SimClass");
        object instanceOfMyType = Activator.CreateInstance(type);

        object[] Args1 = new object[1]; Args1[0] = -1;
        object result = type.InvokeMember("GeneralMethod1",
              BindingFlags.Default | BindingFlags.InvokeMethod,
                   null,
                   instanceOfMyType,
                   Args1);

but have problem in invoking “GeneralMethod2”:

    Input input = new Input { Numberi = -5};
    object[] Args2 = new object[1]; Args2[0] = input;
    object output = type.InvokeMember("GeneralMethod2",
          BindingFlags.Default | BindingFlags.InvokeMethod,
               null,
               instanceOfMyType,
               Args2);

would you please advise what is my mistake?

  • 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-16T06:58:01+00:00Added an answer on June 16, 2026 at 6:58 am

    I suspect the problem is that you’ve got a different Input class. You’re loading SimFile.dll dynamically, but creating an instance of Input statically. That means the Input class you’re creating isn’t the same as the one in the assembly you’re invoking the method in.

    If you already have a reference to SimFile.dll in your code, you shouldn’t load it explicitly – that’s just going to confuse things. If you don’t have a reference to SimFile.dll in your project, then presumably you’re creating an instance of a completely different Input type.

    Either way, you should be able to fix the problem by using the Input class within the dynamically-loaded assembly:

    Type inputType = assembly.GetType("Input")
    object input = Activator.CreateInstance(inputType);
    inputType.GetProperty("Numberi").SetValue(input, -5);
    
    // Rest of code as before
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple database table that joins two other tables in a
I have a very simple scenario, using NHibernate: one abstract base class animal; two
I have two arrays, one is very large (more than million entries) and other
I have two very similar usecases, one works, and another one does not. I
I have two simple classes, very simple One is like master table and contains
I have two very simple routes routes.MapRoute( post, // Route name postPage + /{slug},
I have two very simple, identical UITableViews in my app that are populated with
The situation is very simple, I have two panel. In the event of OnMouseOver
I have a very simple table with two columns, but has 4.5M rows. CREATE
I have a very simple form with a name field and two submit buttons:

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.