Mono.Addin implementation doesn't retrieve addins

我的梦境 提交于 2019-12-01 06:04:58

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/13417219/mono-addin-implementation-doesnt-retrieve-addins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!