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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:35:46+00:00 2026-05-27T04:35:46+00:00

I have a piece of dissassembled code which didn’t work quite well around some

  • 0

I have a piece of dissassembled code which didn’t work quite well around some reflection code. I have no idea on how to make it valid as I don’t know how to work with MethodHandles etc… I think it should be a pretty simple task for a reflection guru because (as far as I can deduct) the only thing that needs to happen is ‘getting a method handle from an interface’? Am I correct?

The following parameter is wrong.. IProductRepositoryItem.Code should be a RuntimeMethodHandle

(MethodInfo) MethodBase.GetMethodFromHandle(IProductRepositoryItem.Code));

Full code:

ParameterExpression parameterExpression = Expression.Parameter(typeof (T), "i");
// ISSUE: method reference

Expression<Func<T, object>> property =
    Expression.Lambda<Func<T, object>>(
        (Expression) Expression.Property(
            (Expression) Expression.Convert((Expression) parameterExpression, typeof (IProductRepositoryItem)),
            (MethodInfo) MethodBase.GetMethodFromHandle(IProductRepositoryItem.Code)), 
                new ParameterExpression[1] {
                     parameterExpression
                });
string key = entityHelper.GetField<T>(property);
  • 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-27T04:35:47+00:00Added an answer on May 27, 2026 at 4:35 am

    Assuming your function has no parameters, you should change the entire offending line to this:

    typeof(IProductRepositoryItem).GetMethod("Code");
    

    If it does take parameters, use the appropriate overload of GetMethod.

    EDIT: If you’re trying to access a property, you should use the overload of Expression.Property that takes a PropertyInfo rather than a MethodInfo.

    typeof(IProductRepositoryItem).GetProperty("Code");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of fortran code, and I am not sure which standard
I have piece of javascript code, which should process when the browser window is
I have piece of code which I use to format a range of cells
I have this piece of code, that it refuses to work without the !important
I have a piece of code which inserts a link into a p tag
I have a piece of code here that i really could use some help
I have this piece of code which gives to SAXParseError i.e., it is not
I have a piece of code below which I am trying to use to
I have a piece of code which runs on window resize. I am pulling
I have piece of code in C which removes any duplicate character in a

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.