Mono.Addin implementation does not fetch add-ons

I am writing an extensible application using the Mono.Addins framework, C # and visual studio 2010.

The structure of my application is as follows:

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 (links 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 (draft references 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 this: in the foreach statement, no plugins are received.

ps: all .dlls are compiled in the same directory.

+3
source share
2 answers

The problem is that the extension point for IOrganizerPlugin is defined in project1, which is not an add-on or the root of the add-in. The solution is to add this link to project2:

[assembly: ImportAddinAssembly ("project1.dll")]

Thus, project1 becomes part of the root of the App.Organizer add-in, and the extension points in the project1.dll file are correctly registered.

+5
source

I don’t know why or if there are some reasons for the implementation, but moving the specialized plugin interface (IOrganizerPlugin) inside the same assembly as my plugin.

0
source

Source: https://habr.com/ru/post/984430/


All Articles