I have a factory class which imports a list of IOperation types. I get the following error when I try and resolve the factory class:
Resulting in:
Cannot activate part 'Message36Operation'. Element: Message36Operation --> Message36Operation --> DirectoryCatalog (Path=".\")
Resulting in:
Cannot get export 'Message36Operation (ContractName="IOperation")' from part 'Message36Operation'. Element: Message36Operation (ContractName="IOperation") --> Message36Operation --> DirectoryCatalog (Path=".\")
Resulting in:
Cannot set import 'OperationsFactory.Operations (ContractName="IOperation")' on part 'OperationsFactory'. Element: OperationsFactory.Operations (ContractName="IOperation") --> OperationsFactory --> AssemblyCatalog (Assembly="RmiToODKMessanger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
Here's what I have:
[Export(typeof(OperationsFactory))]
public class OperationsFactory
{
[ImportMany(typeof(IOperation))]
private IEnumerable<IOperation> Operations { get; set; }
}
public interface IOperation
{
}
public abstract class BaseRmiOperation : IOperation
{
}
[Export(typeof(IOperation))]
public class Message36Operation : BaseRmiOperation, IOperation
{
}
The exception is thrown will I try and resolve an instance of the factory.
I can get this to work if I remove the abstract class.
Any ideas,
Thanks,
Ken
** Update:
Below is the BaseRmiOperation class. I'm instantiating a few classes in the cstor and that's it.
I forgot to mention the structure of the app previously.
- CG.App: contains OperationsFactory and bootstrapper class for MEF.
- CG.Plugins : Contains various IOperation implementations such as Message36Operation and the BaseRmiOperation abstract class
- CG.Common : Contains IOperation interface. This assembly is referenced by both CG.App and CG.Plugins
The CG.App.Bootstrapper class loads the plugins from bin/plugins.
public abstract class BaseRmiOperation : IOperation
{
protected SettingsManager _settingsManager;
protected RmiMessenger _messenager;
protected ILogger _logger;
protected TagManager _tagManager;
protected Environments _rmiEnvironment;
protected string _msgSource;
protected string _emp_id;
public BaseRmiOperation()
{
this._settingsManager = new SettingsManager();
this._messenager = new RmiMessenger(null, null);
this._tagManager = new TagManager(); // pass ILogger
//this._logger = logger;
// pulls the rmi_env and a few other settings from
// winCC.
PopulateRmiSettings();
}
public abstract ExitCodes Execute(object[] data);
public abstract string Description { get; }
public abstract string Alias { get; }
[Import]
instances? – Matthew Abbott