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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:13:29+00:00 2026-05-29T19:13:29+00:00

I want to export a generic class to a generic interface via MEF. My

  • 0

I want to export a generic class to a generic interface via MEF. My objects are:

public interface IService<T> { }

[Export(typeof(IService<T>))] // error!!!!!!
public class Service<T> { }

public class Client<T> {
    [Import]
    private IService<T> _service;
}

But when I try to export IService<T>, I get this error:

Attribute argument cannot use type parameters

Can anybody guide me to do this please?

  • 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-29T19:13:31+00:00Added an answer on May 29, 2026 at 7:13 pm

    Try

    [Export(typeof(IService<>))]
    

    To get a generic type definition from the typeof operator, you omit type arguments. For types with more than one type parameter, use commas to indicate the “arity” of the type. For example:

    typeof(List<>)              // not: typeof(List<T>)
    typeof(IDictionary<,>)      // not: typeof(IDictionary<K, V>)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to export a C++ class, which has a member std::vector<int> . How
i want to Export MYSQL data into Excel/CSV via php. so that i can
I want to create an delegate based export for an interface which is called
I want to export the assemblies built in my project. But where are they
I want to export the audio-media of a MOV-File with the QuickTime-API and save
Now I want to export a image in my Project to a folder ,
I am want to export database table to a file. I am using the
I have a simple report that I want to export to a CSV file.
I have a huge IQueryable that I want to export directly to Excel for
I'm writing a C/C++ DLL and want to export certain functions which I've done

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.