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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:36:33+00:00 2026-06-04T16:36:33+00:00

I want to invoke a method on a class that i have a reference

  • 0

I want to invoke a method on a class that i have a reference to. The method that I want to call has a custom attributes. Currently I can find this attributes and call the property of my class Attribute.

is there a way to invoke that method ?

PS/ The project is written in vbnet, but I think the solution is the same in c#.

  • 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-04T16:36:34+00:00Added an answer on June 4, 2026 at 4:36 pm

    If you can find the attributes I guess you have the MethodInfo of that method(s). Simply call the MethodInfo.Invoke method, you have to specify the instance of the object you want to use (or null if it’s a static method) and all the parameters to pass to the method (in the same order of the prototype).

    For example if you have to invoke a method with this prototype:

    void Foo(string name, int value);
    

    And you have a function to find that method (making a search for a given attribute):

    MethodInfo FindMethodWithAttribute(Type attributeType, Type objectType);
    

    You can find and invoke that method (of a hypothetical object anObject) with this code:

    MethodInfo method = FindMethodWithAttribute(
        typeof(MyAttribute), // Type of the "marker" attribute
        anObject.GetType()); // Type of the object may contain the method
    
    method.Invoke(anObject, new object[] { "someText", 2 });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to invoke a selector of a method that has the usual NSError**
my application want to call a method of a class that is from another
I have a class that extends RemoteServiceServlet. This class has several methods, in one
I have a method call that returns Type . I want to make use
I want to specifically invoke the base class method; what's the most concise way
How can I invoke a method with parameters using reflection ? I want to
I have a button that when i tap on it i want to invoke
I have a WCF application that is using NetTcpBinding . I want to invoke
How can I Invoke a method in a class whenever a method in the
So I have this method that get executed repeatedly public static boolean isReady(String dirPath,

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.