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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:28:01+00:00 2026-06-09T10:28:01+00:00

this is a dummy example what I am trying to do: var ass =

  • 0

this is a dummy example what I am trying to do:

var ass = Assembly.Load("Dummy.Class.FullName");

var yy =
    from t in ass.GetTypes()
    let attributes = t.GetCustomAttributes(typeof(MyTestAttribute), true)
    where attributes != null && attributes.Length > 0
    select new { Type = t, Attributes = attributes.Cast<MyTestAttribute>() };

foreach (var x in yy)
{
    TestOpen<typeof(x.Type)>();
}

private void TestOpen<TEntity>() where TEntity : Entity, new()
{
}

I can´t get a class definition and pass to a generic method this way, I tried everything, I guess I am missing something in special that the method is waiting some compiled class and from reflection I can´t get this, correct?

cheers

  • 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-09T10:28:02+00:00Added an answer on June 9, 2026 at 10:28 am

    You can use MakeGenericMethod to generate the proper method definition, and call it via reflection.

    Type thisType = this.GetType();
    
    var mi = thisType.GetMethod("TestOpen");
    
    foreach (var x in yy)
    {
        var gmi = mi.MakeGenericMethod(x.Type);
        gmi.Invoke(this, null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem. This is my code: var method = new DynamicMethod(dummy, null, Type.EmptyTypes);
I have the following dummy class structure and I am trying to find out
The example I'm trying to compile is from: http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/examples.html (the chat example) Here is
I bumped into this behaviour when trying to get class-decorators and method-decorators to play
I am trying to create a dummy wrapper class ( a mongoengine Document )
This probably is a dummy question but I cannot find a clear indication. I
This might be a dummy question, but I cannot find any clue in all
Ok, I've an array of dummy objects containing property cgpath. This is called darkPathArray
I've been trying to solve this mystery almost 2 hours, this is giving me
this question is according to this topic: creating a huge dummy file 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.