I ran into an ArgumentException setting up a custom plug-in decorated with the IFrameComponent attribute today; I wanted to have it appearing in the right hand area of the EPiServer edit mode.
namespace MyProject.Core.MyPlugIn { [IFrameComponent(PlugInAreas = PlugInArea.AssetsDefaultGroup, Url = "/episerver/MyProject/MyPlugIn/MyCustomPlugIn/Index", Title = "Some custom plugin")] [Authorize(Roles = "WebEditors")] public class MyCustomPlugInController : Controller { public ActionResult Index() { var model = new MyCustomPlugInViewModel(); return View("~/MyPlugIn/MyCustomPlugIn.cshtml", model); } } }
After setting up all views, models and so on, I got the following exception when I tried accessing the site.
Server Error in '/' Application. Unable to find a module by assembly 'MyProject.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' Parameter name: moduleAssembly Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Unable to find a module by assembly 'MyProject.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' Parameter name: moduleAssembly
I fixed this problem by adding my assembly to the protectedModules section of the web.config file (lines 571-575).
web.config
<episerver.shell> <publicModules rootPath="~/modules/" autoDiscovery="Modules" /> <protectedModules rootPath="~/EPiServer/"> <add name="MyProject"> <assemblies> <add assembly="MyProject.Core" /> </assemblies> </add> <add name="Shell" /> <add name="CMS" /> <add name="EPiServer.Packaging.UI" /> </protectedModules> </episerver.shell>