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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:06:07+00:00 2026-05-14T22:06:07+00:00

Apparently .NET 4.0 does not have the PartCreator/ExportFactory for non-SL. Which is something I

  • 0

Apparently .NET 4.0 does not have the PartCreator/ExportFactory for non-SL. Which is something I think I need for this.

I was wondering if someone can help me (with an example please) of how to create multiple instances of the EXPORTED type in a DLL. Basically say I have a DLL that contains a type ConsoleLogger and it uses the interface ILogger (which I import/export through MEF)…How would I create an instance of ConsoleLogger whenever I wanted to? Also..Is this even possible?

  • 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-14T22:06:08+00:00Added an answer on May 14, 2026 at 10:06 pm

    One way to do this is to write a factory for the logger yourself and use that as the contract you export.

    public class Logger : ILogger
    {
        public Logger(IFoo foo) { }
        // ...
    }
    
    [Export(typeof(ILoggerFactory))]
    public class LoggerFactory : ILoggerFactory
    {
        [Import]
        public IFoo Foo { get; set; }
    
        public ILogger CreateLogger()
        {
            return new Logger(Foo);
        }
    }
    

    Then you just import a LoggerFactory, and call CreateLogger every time you need a logger. This is pretty much the same thing you would do if you imported ExportFactory. The downside is that you have to write a separate factory for each thing you want to be able to create multiple instances of.

    Another option is to add an ExportProvider to your container that allows you to import factories. In the latest MEF drop on CodePlex, there is a DynamicInstantiation sample which shows how to do this.

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

Sidebar

Related Questions

Apparently mutableCopy copies by reference, not value. Ie if I do this: NSMutableArray arrayA
I use asp.net 4 c# and ef4. I have this code, it should compile
I have tested this in IIS 6.1, IE 7, ASP.NET 3.5 SP1. I have
I have a need to parse Bezier Path Strings, but apparently the System.Windows.Media.Geometry version
Does such a thing exist? I have a customer files that are apparently invalid
So I have this SDK provided by a third party which is used for
I have an ASP.NET Web Application which has a reference to 'C:\references\Utils.Varia.dll'. There is
The .net framework 4 is apparently going to include a BigInteger class. However, I
My program connects to an IRC room on freenode.net, it uses port 6667, apparently
Apparently, there's been a big brouhaha over whether or not Python needs tail-call optimization

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.