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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:48:07+00:00 2026-05-21T03:48:07+00:00

I have 2 types called Effect and EffectMethods which is the static class I

  • 0

I have 2 types called Effect and EffectMethods which is the static class I am calling the method of:

public class EffectMethods
{
    public static EffectResult Blend (Effect effect)
    {
        bool success = true;
        return new EffectResult ( effect.Type, success );
    }
}

I find the right method using:

Type.GetMethods ( BindingFlags.Public | BindingFlags.Static );

and filter out the right one.

But when I call it:

( EffectResult ) method.Invoke ( null, new object [ ] { this } );
public class Effect
{
    public EffectResult Apply()
    {
        var methods = Type.GetMethods ( BindingFlags.Public | BindingFlags.Static );
        var method = methods.First ( ... );

        // This result value is now different (success = false)
        return ( EffectResult ) method.Invoke ( null, new object [ ] { this } );
    }
}

I am getting the wrong result. Here this is the current instance of Effect because it’s the type that includes the reflection call.

Basically one of the values I calculate is a flag that returns whether the operation is successful. But this value is set to true in code, but after the method returns via reflection the result is different.

Am I doing this wrong? Is there something I am missing? I can clearly see the value to be true inside the method but on the call site, it shows up differently.

  • 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-21T03:48:07+00:00Added an answer on May 21, 2026 at 3:48 am

    I don’t see why it should return “bad value”. You didn’t provide complete code, so I can only give you my two guesses.

    1. In the constructor of EffectResult, you forgot to set the success parameter to a property, or the property implementation is wrong.

    2. The Type you use to get the methods from is other than EffectMethods or you have duplicate assemblies with different implementations in your AppDomain. Check the loaded Modules.

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

Sidebar

Related Questions

I have several types of entities, each with their own fields, which are stored
I have 6 classes, which are all document types. All the document types have
I have some generic types, like the following: public struct Tuple<T1, T2> { ...
I'm working on a code base in which we have several configurable types. One
Suppose I have a function which looks like this: template <class In, class In2>
I have following entity class User: public class User implements Serializable { @Column(length =
I have the types Rock , Paper , and Scissors . These are components,
Seeing as Java doesn't have nullable types, nor does it have a TryParse(), how
My DataGridView needs to support a number of types and these types may have
I want to accomplish the following scenario in Drupal: You have 2 content-types. Lets

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.