mef

Can I control object creation using MEF?

I need to add some extension points to our existing code, and I've been looking at MEF as a possible solution. We have an IRandomNumberGenerator interface, with a default implementation (ConcreteRNG) that we would like to be swappable. This sounds like an ideal scenario for MEF, but I've been having problems with the way we instantiate t...

Getting an export from an MEF container given only a Type instance

I have a scenario where I have to get an export from my CompositionContainer instance but I only have a Type to work with; I don't know the type at compile time, hence I can't retrieve the exported object in the normal generic way. Normally you would do this: _container.GetExportedObject<IMyType>(); But in my case, I have this: Type...

Resources and Examples of using MEF for DI/IoC

I've searched high and look for samples about using MEF for DI. I know its not DI but from what I hear (really hear in podcasts) it can be used as such...but I can't find any blog posts or samples. I am using MEF in this project already (to support plugins) and thought it would be nice to leverage for DI also. Maybe I am barking up the...

How to use DLR with MEF in .Net 4.0?

There were promises from the MEF team that MEF will support DLR plugins in the .Net 4.0. Did it happen already and I can [Import] some IronPython objects? If yes, any links to the topic would be helpful. ...

Regex blows up in an editor extension

I am building a Visual Studio editor extension for my Django rendering engine. I just started it so so far it is really simple and so far it does what I expect it to do - highlighting and the such. Or it did until I started to add parsing logic. Part of the parsing relies on regular expressions. And here is my problem: No matter how I t...

App.Current.MainWindow changes when launching another dialog?

I am launching a new dialog from a MEF plugin when I start up the application. Could someone explain why this changes App.Current.MainWindow to the dialog that was launched from the plugin? How can I prevent this from happening? ...

MEF: Calling Refresh() on a DirectoryCatalog throws ChangeRejectedException if new DLLs found in directory (C#)

I'm experimenting with MEF and created a test program to call "plugins" that implement some given interface, which follows: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ProbeContract { public interface IProbe { int DoProbe(string what); List<string> GetCapabilit...

Does MEF (Managed Extensibility Framework) do "duck" typing?

I have 2 assemblies: Assembly 1: interface IWeapon { int Might { get; } } [Export("sword")] public class Sword : IWeapon { public int Might { get { return 10; } } } Assembly 2: interface IWeapon { int Might { get; } } var catalog = new AssemblyCatalog(typeof(Ninja.Sword).Assembly); var container = new C...

Visual Studio 2010 addin writing articles/tutorials?

Does anyone know of some good articles / tutorials on writing addins/plugins for Visual Studio 2010? ...

Is it possible (and reasonable) to use MEF and Prism (CAL) in one project?

Hey girls and guys! I am currently working on a WPF project using Prism (CAL) and am wondering if it is a good idea to use both Prism and MEF in one project. I would use Prism for modularity and MEF for extensibility. My project is a paint-like application so Prism would provide the module-separation (toolbox, canvas as modules etc.) a...

MEF: Loading parts (plug-ins) which have differing properties.

Brief Background: My team has decided to use Microsoft's Managed Extensibility Framework (MEF) in order to provide an extensible model for adding new "providers" into our system. This allows for us to plug in new 3rd party providers with relative ease. Note: I was impressed by how simple MEF was to use and get up and running with. My...

MEF vs. any IoC

Looking at Microsoft's Managed Extensibility Framework (MEF) and various IoC containers (such as Unity), I am failing to see when to use one type of solution over the other. More specifically, it seems like MEF handles most IoC type patterns and that an IoC container like Unity would not be as necessary. Ideally, I would like to see a ...

Mef and asp.net problem

I have an asp.net application using a model assembly (with a Model class) for business logic. This model assembly has a dependency on a MailService through an IMailService interface and I am trying to use MEF to fill the Models need for a MailService implementation. I am doing the MEF composition in the contructor of the Model class. Th...

MEF: a replacement for PRISM?

To what extent, if any, is MEF a replacement for PRISM? ...

Should MEF be used in a production application

Hi, I currently need to provide a means of adding extensibility in my application. I'm currently looking at MEF and MAF. MEF provides a simpler programming model, and also fits our usage scenarios better as we only want to load addins into a single AppDomain - this is due to the way the system has been architected. The same thing can...

MEF - Do I need to implement IPartImportsSatisfiedNotification

public interface IPlugin { public bool execute(); } All my "parts" implement this IPlugin interface. My parts obviously have Import/Export requirements/offerings. I'm writing a build+config system, in which the user dynamically selects what he/she wants, which translates to a set of plugins being called. For example, here's a lis...

How should I create plugins with multiple instances in C#?

My ultimate goal is to load controls as plugins, for use as DocumentContent in AvalonDock. As a result, I will need to be able to create multiple instances of these controls, and I would prefer to do so with as limited overhead for the Plugin creators as possible. My initial intention was to use MEF to locate and manage my plugins, but ...

Merging Resource Dictionaries dynamically at runtime (for plugins)

I am using the Managed Extensibility Framework for a WPF application. I've defined interfaces for so-called extension points which provide new features to the application. Some of these features might be to display data using certain data templates, which is something which you will probably want to specify in a xaml resources file. If...

How does one import multiple plugin/parts using MEF?

I'm new to MEF and am trying to use it to build a plug-in system, but am stuck at step one. I'm following an article by Andrew Whitechapel. I've downloaded his sample code an it runs OK (if you remove one of the "exporting" assemblies - they are mutually exclusive in his sample - and reference the MEF assembly). The sample illustrates ...

Expose version of MEF loaded "plugin"

Hi all apologies for the title, I got stuck for words I'm dipping my toes in the MEF pond. So far, so good. I've got a host app and a couple of "plugin" assemblies that export things. The host app defines an attribute called DescriptionAttribute which inherits from ExportAttribute and has a simple Name property. My test form has an <Im...