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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:58:08+00:00 2026-05-15T04:58:08+00:00

I have the following interface: public interface PluginInterface<T> where T : MyData { List<T>

  • 0

I have the following interface:

public interface PluginInterface<T> where T : MyData
{
    List<T> GetTableData();
}

In a separate assembly, I have a class that implements this interface. In fact, all classes that implement this interface are in separate assemblies. The reason is to architect my app as a plugin host, where plugin can be done in the future as long as they implement the above interface and the assembly DLLs are copied to the appropriate folder.

My app discovers the plugins by first loading the assembly and performs the following:

List<PluginInterface<MyData>> Plugins = new List<PluginInterface<MyData>>();
string FileName = ...;//name of the DLL file that contains classes that implement the interface
Assembly Asm = Assembly.LoadFile(Filename);
foreach (Type AsmType in Asm.GetTypes())
{
    //Type type = AsmType.GetInterface("PluginInterface", true);   //
    Type type = AsmType.GetInterface("PluginInterface<T>", true);
    if (type != null)
    {
       PluginInterface<MyData> Plugin = (PluginInterface<MyData>)Activator.CreateInstance(AsmType);

       Plugins.Add(Plugin);
    }
}

The trouble is because neither line where I am getting the type as by doing Type type = … seems to work, as both seems to be null. I have the feeling that the generic somehow contributes to the trouble. Do you know why?

  • 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-15T04:58:08+00:00Added an answer on May 15, 2026 at 4:58 am

    It looks like you have to use the mangled interface name when querying for the interface:

    Type type = AsmType.GetInterface("PluginInterface`1", true);
    

    From MSDN:

    For generic interfaces, the name parameter is the mangled name, ending with a grave accent (`) and the number of type parameters. This is true for both generic interface definitions and constructed generic interfaces. For example, to find IExample<T> or IExample<string>, search for “IExample`1”.

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

Sidebar

Related Questions

Assuming that I have the following interface and class: public interface IFooRepo : IDisposable
I have following design requirements: interface Server {} public class ServerImpl implements Server {}
I have the following method and interface: public object ProcessRules(List<IRule> rules) { foreach(IRule rule
I have the following class definition: public interface IItem{} public class FirstObject<T, U> :
I have this following interface : public interface FruitDetails { public String getFruitName(); }
Let's say that I have the following interface: public interface IMyService { void SimpleMethod(int
I have following interfaces public interface IReport<TInput, TOutput> { List<TOutput> GenerateReport(TInput input); } public
I have the following: public class InstanceList : List<Instance> {} I would like to
Imagine we have following classes: public interface MyInterface<T> { List<T> getList(T t); } abstract
I have the following interface: public interface IPlateSubCategory<T> { T GetItem(int plateID); } And

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.