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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:37:21+00:00 2026-05-16T20:37:21+00:00

I am getting an InvalidOperationException with the message: Late bound operations cannot be performed

  • 0

I am getting an InvalidOperationException with the message:

“Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.”

The following is the relevant part of the code:

// Gets the entity type of the table to update.
Type entityType = Jobs.GetType(syncSettings.TableToUpdate);

// Creates a generic list with the same type to hold the records to update.
Type listType = typeof(List<>).MakeGenericType(entityType);
object recordsToUpdate = Activator.CreateInstance(listType);

// Fills the list recordsToUpdate...
// A few lines below, I try to call the extension method ElementAt:
MethodInfo elementAtMethod = typeof(Enumerable).GetMethod("ElementAt", BindingFlags.Static | BindingFlags.Public);
elementAtMethod.MakeGenericMethod(entityType);

object record = elementAtMethod.Invoke(
                                     recordsToUpdate,
                                     new object[] { recordsToUpdate, recordIndex });

In my last action, the exception mentioned above is thrown. What am I doing wrong? What does this error mean?

I have been investigating and it seems that the method parameter type T is still generic. That’s why ContainsGenericParameters is true. How do I set the parameter to the entityType?

  • 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-16T20:37:22+00:00Added an answer on May 16, 2026 at 8:37 pm

    Simply , you haven’t caught the result of MakeGenericMethod (it returns a different MethodInfo representing the closed method)

    elementAtMethod = elementAtMethod.MakeGenericMethod(entityType);
    

    However, might I suggest that in most cases it is easier to use the non-generic IList, falling back to non-generic IEnumerable (reflection and generics are not good friends):

    IList list = recordsToUpdate as IList;
    if(list != null) return list[recordIndex];
    // fallback to IEnumerable
    if(recordIndex < 0) throw new IndexOutOfRangeException();
    IEnumerable enumerable = (IEnumerable)recordsToUpdate;
    foreach (object item in enumerable) {
        if (recordIndex-- == 0) return item;
    }
    throw new IndexOutOfRangeException();
    

    (note, you won’t have to use the fallback code, since you are always using List<T> which implements IList)

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

Sidebar

Related Questions

I keep getting the following InvalidOperationException : The relationship between the two objects cannot
I'm trying to update a hashtable in a loop but getting an error: System.InvalidOperationException:
I getting the following error when I try to connect to my server app
After getting the objectEnumerator in the following code, the set1 retain count goes to
I'm trying to have overloaded methods in a web service but I am getting
I'm getting the following error in my MVC2 app using Linq to SQL (I
I am getting an InvalidOperationException('DeferRefresh' is not allowed during an AddNew or EditItem transaction.)
I'm getting a InvalidOperationException when trying to run this code: database.Produkts.SingleOrDefault<Produkt>(x => x.Kod ==
i keep getting this error: Exception Details: System.NotSupportedException: Cannot serialize member HannaPrintsDataAccess.Customer.CustomerAddresses of type
Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the

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.