Composition produced a single composition error

Viewed 2321

I am trying to use the MvcPluginFramework. I know that it is out of date, but I thought would take a stab at upgrading it. However, I have come across a problem in my code when I try to render the plugin into the view I get the following exception:

  • $exception "The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.\r\n\r\n1) Cannot create an instance of type 'PaypalPlugin.PayPalPlugin' because a constructor could not be selected for construction. Ensure that the type either has a default constructor, or a single constructor marked with the 'System.ComponentModel.Composition.ImportingConstructorAttribute'.\r\n\r\nResulting in: Cannot activate part 'PaypalPlugin.PayPalPlugin'.\r\nElement: PaypalPlugin.PayPalPlugin --> PaypalPlugin.PayPalPlugin --> DirectoryCatalog (Path=\"C:\Projects\solitudeec2core\solitudeeccore\solitude.admin\solitude.admin\bin\")\r\n\r\nResulting in: Cannot get export 'PaypalPlugin.PayPalPlugin (ContractName=\"Kusog.Mvc.IMvcPlugin\")' from part 'PaypalPlugin.PayPalPlugin'.\r\nElement: PaypalPlugin.PayPalPlugin (ContractName=\"Kusog.Mvc.IMvcPlugin\") --> PaypalPlugin.PayPalPlugin --> DirectoryCatalog (Path=\"C:\Projects\solitudeec2core\solitudeeccore\solitude.admin\solitude.admin\bin\")\r\n" System.ComponentModel.Composition.CompositionException

I am trying to render the html from the controller PayPal so I used the following html helper tag which crashes on this piece of code.

/// <summary>
/// Uses MEF to get all plugins defined and get them setup for use in the site.
/// </summary>
/// <remarks>This code does not attempt to only call SetupExtensions once for a given plugin.  
/// Each time this method is called, all plugins found will have their SetupExtensions method
/// called.  This is intended to be called once during application startup.</remarks>
protected virtual void refreshPlugins()
{
    try
    {
        m_pluginsContainer = new CompositionContainer(addMefCatalogs(new AggregateCatalog()));
        m_pluginsContainer.ComposeParts(this);
    }
    catch (CompositionException compositionException)
    {
        Console.WriteLine(compositionException.ToString());
    }
    catch (ReflectionTypeLoadException ex)
    {
        StringBuilder sb = new StringBuilder();
        foreach (Exception exSub in ex.LoaderExceptions)
        {
            sb.AppendLine(exSub.Message);
            if (exSub is FileNotFoundException)
            {
                FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                {
                    sb.AppendLine("Fusion Log:");
                    sb.AppendLine(exFileNotFound.FusionLog);
                }
            }
            sb.AppendLine();
        }
        string errorMessage = sb.ToString();
        //Display or log the error based on your application.
    }
    foreach (Lazy<IMvcPlugin, IMvcPluginData> plugin in m_plugins)
    {
        plugin.Value.SetupExtensions(this);
    }
}

EDIT 2

The following is to show my con-structures for the plugin initialisation

using Kusog.Mvc;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace PayPal.Controllers
{

    [DynamicActionFilter]
    public class PayPalController : Controller
    {

        public ActionResult Index()
        {
            return View("~/Views/Paypal/Index.cshtml");
        }



        public ActionResult PageFooter()
        {
            return Content("");
        }
    }
}

Edit 3

PayPalPlugin.cs 

{
    /// <summary>
    /// Provides basic plugin functionality to show how to set it up.
    /// </summary>
    /// <remarks>This plugin inherits from DemoAppPlugin rather than BaseMvcPlugin because it wants to use extended functionality made available in DemoAppPlugin, such as adding menu items.
    /// If a plugin doesn't need to do things other than what is provided in BaseMvcPlugin, it should inherit from that to be usable in other implementations of the plugin framework.</remarks>
    [Export(typeof(Kusog.Mvc.IMvcPlugin))]
    [MvcPluginMetadata("PayPalPlugin", null, "PayPalPlugin", "This is a plugin to be used for Solutide E-Commerce Platform to allow Paypal.")]
    public class PayPalPlugin : DemoAppPlugin
    {
        public override void SetupExtensions(IMvcPluginApplication app)
        {
            base.SetupExtensions(app);

            addLocalCss("/Content/simple.css");
            addFooterScript("ksgSimple", "/Scripts/ksgSimple.js", null);
            AddActionFilter("Index", "PayPalPlugin", new ActionExtension("Index", "PayPal"));

            AddActionFilter("Metatags", "PluginDemo", new ActionExtension("Metatags", "Simple"));

        }
    }
0 Answers
Related