Reputation: 7629
I'm writing an extendible application using Mono.Addins framework, C# and visual studio 2010.
the structure of my application is the following:
project1:
namespace Plugins
{
[TypeExtensionPoint]
public interface IPlugin<InitParamsType>
{
void Refresh();
string PlugInName { get; }
void Initialize(InitParamsType parameters);
}
[TypeExtensionPoint]
public interface IOrganizerPlugin : IPlugin<string>
{
bool AllowsToEditBrandCode { get; }
UserControl GetUI();
}
public interface IPluginHost<PluginSpecalizedType>
{
void EmbedPlugin(PluginSpecalizedType plugin);
}
}
project 2 (references project1):
[assembly: AddinRoot("App.Organizer", "1.0")]
namespace App.Organizer
{
public partial class frm_Supplier_Managed : Form, IPluginHost<IOrganizerPlugin>
{
public frm_Supplier_Managed()
{
AddinManager.Initialize();
AddinManager.Registry.Update(null);
foreach (IOrganizerPlugin Addin in AddinManager.GetExtensionObjects(typeof(IOrganizerPlugin)))
{
EmbedPlugin(Addin);
}
}
public void EmbedPlugin(IOrganizerPlugin plugin)
{
//embedding UI and so on..
}
}
}
project 3 (references project 1):
[assembly: Addin("App.OrganizerPro", "1.0")]
[assembly: AddinDependency("App.Organizer", "1.0")]
namespace App
{
[Extension]
public class MainPlugIn : IOrganizerPlugin
{
public void Refresh()
{
return;
}
public string PlugInName
{
get { return ""; }
}
public void Initialize(string supplierCode)
{
}
public UserControl Interface
{
get { return null; }
}
public bool AllowsToEditBrandCode
{
get { return true; }
}
public UserControl GetUI()
{
return null;
}
}
}
the problem is: in the foreach statement no plugins are yielded.
p.s.: all .dll are compiled in the same directory.
Upvotes: 3
Views: 567
Reputation: 1737
The problem here is that the extension point for IOrganizerPlugin is defined in project1, which is not an addin nor an add-in root. The solution is to add this reference in project2:
[assembly:ImportAddinAssembly ("project1.dll")]
In this way project1 becomes part of the App.Organizer add-in root, and the extension points in project1.dll will be correctly registered.
Upvotes: 5
Reputation: 7629
Don't know why or if there are some implementing reasons but moving the specialized plugin interface (IOrganizerPlugin) inside the same assembly as the plugin host works for me.
Upvotes: 0