MEF不再看到我的班级之一

问题描述 投票:0回答:1

我有这堂课:

[Export(typeof(IUtility))]
public class DataExporter : IUtility
{
    private int maxRows = int.MaxValue;
    private int sampleRate = 1;
    // etc
}

而且我正在像这样将其导入MEF:

[ImportMany]
public ISet<IUtility> Utilities { get; set; } = new HashSet<IUtility>();

private void Run(params string[] args)
{
    // find all commands that are defined in this assembly
    var catalog = new AggregateCatalog();
    catalog.Catalogs.Add(new AssemblyCatalog(typeof(Program).Assembly));
    // TODO: figure out why loading assemblies from the executable's folder is crashing
    //catalog.Catalogs.Add(new DirectoryCatalog(Path.GetDirectoryName(typeof(Program).Assembly.Location)));
    container = new CompositionContainer(catalog);
    container.ComposeParts(this);
    // etc
}

static void Main(string[] args)
{
    Instance.Run(args);
}

前几天工作,但是到今天为止,我的DataExporter类尚未导入到实用程序集合中。但是,我所有其他实用程序类都是-这个有什么问题?

c# mef
1个回答
0
投票

我想通了,我选择了一个构建配置,该配置将包含类的项目排除在外。我进行了这些设置以节省构建时间(在任何给定时间仅构建我需要的项目)。

© www.soinside.com 2019 - 2024. All rights reserved.