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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:47:28+00:00 2026-06-02T06:47:28+00:00

It is strange but the source code public class Processor<T> where T: class {

  • 0

It is strange but the source code

public class Processor<T> where T: class
{
...
    private object WorkWithSubtype(IRequester nextRequester, Type type)
    {
        if (type.GetInterface("IList") != null)
        {
            var originalType = type.GetGenericArguments()[0];
            var list = Activator.CreateInstance(type);

            var method = typeof(Processor<>).GetMethod("GetObjects", BindingFlags.NonPublic | BindingFlags.Instance).MakeGenericMethod(originalType);
            var resList = method.Invoke(this, new object[] { nextRequester });
            typeof(List<>).GetMethod("AddRange").MakeGenericMethod(originalType).Invoke(list, new object[] { resList });
            return list;
        }
    }

    private IEnumerable<K> GetObjects<K>(IRequester requester) where K: class
    {
        ...
        //We can call method WorkWithSubtype in this method sometimes
    }
}

And i get “Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.”. The exception is throwing at line ‘var resList = method.Invoke(this, new object[] { nextRequester });’. Can you help me? Thanks in advance!

  • 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-02T06:47:32+00:00Added an answer on June 2, 2026 at 6:47 am

    You have two generic parameters: one is for the Processor class; the other is for the GetObjects method. In making the generic method, you’ve supplied a type argument for the method’s type parameter, but you haven’t supplied a type argument for the class’s generic parameter.

    Depending on the purpose of the processor class, you could try one of the following solutions:

    • build the closed generic type with a type argument
    • use typeof(Processor<T>) rather than using reflection to build the closed generic type
    • remove the type parameter from the class
    • remove the type parameter from the method

    I think the second is most likely to be what you’re looking for:

    var method = typeof(Processor<T>)
        .GetMethod("GetObjects", BindingFlags.NonPublic | BindingFlags.Instance)
        .MakeGenericMethod(originalType);
    

    Additionally, AddRange is not a generic method; rather, List<> is a generic type, so:

    typeof(List<>)
        .MakeGenericType(originalType)
        .GetMethod("AddRange")
        .Invoke(list, new object[] { resList }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might seam like a strange question but.... public string MyProperty { get {
Strange thing...theres no code this time but the using System.ServiceProcess; import gets a red
Quite often I see source code where language's keyword are replaced with full type
This is a strange one, I have everything working but in the controller code
I have some strange problem. I think I followed documentation correctly but my code
I am looking over some open source code and they listed some strange instance
i know, this is strange but, -[NSNull _isNaturallyRTL]: unrecognized selector sent to instance 0x20dfcd8
Hello there once again... I came up with an strange idea but I have
I am iterating over hashmap, but these strange brackets [ ] are there while
I am trying to create a simple line chart, but something strange is happening

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.