I tried to compile the MEF code copied from this page.
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using System;
public class Program
{
[Import]
public IMessageSender MessageSender { get; set; }
public static void Main(string[] args)
{
Program p = new Program();
p.Run();
}
public void Run()
{
Compose();
MessageSender.Send("Message Sent");
}
private void Compose()
{
AssemblyCatalog catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
var container = new CompositionContainer(catalog);
container.ComposeParts(this);
}
}
public interface IMessageSender
{
void Send(string message);
}
[Export(typeof(IMessageSender))]
public class EmailSender : IMessageSender
{
public void Send(string message)
{
Console.WriteLine(message);
}
}
When I run this command dmcs example.cs
I got this error message.
ex.cs(1,29): error CS0234: The type or namespace name `Composition' does not exist in the namespace `System.ComponentModel'. Are you missing an assembly reference?
What reference library do I need to give to remove this error message?
ADDED
dmcs ex.cs /r:System.ComponentModel.Composition.dll
works. One doesn't have to download the dlls from codeplex.