The IControllerFactory ... did not return a controller for the name 'Home'.

Apr 29, 2013 at 10:31 AM
Edited Apr 29, 2013 at 8:20 PM
Hello
I tried add new plugin to your sample project mvc 4 integration.
I created new mvc 4 project called "TestPlugin" and coppied it to Asp.net MVC 4 Integration_test\MvcOSGi.Shell\Plugins.
Then I included TestPlugin(add existing project) in main solution (in Plugins dir).
I have added Manifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<Bundle xmlns="urn:uiosp-bundle-manifest-2.0" Name="TestPlugin" SymbolicName="TestPlugin" Version="1.0.0.0" InitializedState="Active">
  <Activator Type="TestPlugin.Activator" Policy="Immediate" />
  <Runtime>
    <Assembly Path="bin\TestPlugin.dll" Share="false" />
  </Runtime>

  <Extension Point="SidebarMenu">
    <Item url="#" text="TestPlugin_TEST" order="0"/>
  </Extension>
  
</Bundle>
and Activator.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UIShell.OSGi;

namespace TestPlugin
{
    public class Activator : IBundleActivator
    {
        public void Start(IBundleContext context)
        {
            
        }

        public void Stop(IBundleContext context)
        {
            
        }
    }
}
Project rebuild without errors.
After a run I got an error in IE:

"The IControllerFactory 'UIShell.OSGi.MvcCore.BundleRuntimeControllerFactory' did not return a controller for the name 'Home'. "
[InvalidOperationException: The IControllerFactory 'UIShell.OSGi.MvcCore.BundleRuntimeControllerFactory' did not return a controller for the name 'Home'.]
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +444064
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
log output:
Mon, 29 Apr 2013 12:36:36 GMT|   |EventDispatcherThread|UIShell.OSGi.Logger|Debug|   Loaded assembly: 'System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Mon, 29 Apr 2013 12:36:37 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Error|   Failed to load assembly 'System.Web.Mvc.resources, Version=4.0.0.0, Culture=pl-PL, PublicKeyToken=31bf3856ad364e35'.
Mon, 29 Apr 2013 12:36:37 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Error|   Failed to load assembly 'System.Web.Mvc.resources, Version=4.0.0.0, Culture=pl-PL, PublicKeyToken=31bf3856ad364e35'.
Mon, 29 Apr 2013 12:36:37 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Error|   Failed to load assembly 'System.Web.Mvc.resources, Version=4.0.0.0, Culture=pl, PublicKeyToken=31bf3856ad364e35'.
Mon, 29 Apr 2013 12:36:37 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Error|   Failed to load assembly 'System.Web.Mvc.resources, Version=4.0.0.0, Culture=pl, PublicKeyToken=31bf3856ad364e35'.
Mon, 29 Apr 2013 12:36:51 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Debug|   Loaded assembly: 'SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Mon, 29 Apr 2013 12:36:51 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Debug|   Loaded assembly: 'System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Mon, 29 Apr 2013 12:37:28 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Debug|   Loaded assembly: 'System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Mon, 29 Apr 2013 12:38:36 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Error|   Failed to load controller 'Home' since the plugin name is not specified.
Mon, 29 Apr 2013 12:38:40 GMT|   |FrameworkThread|UIShell.OSGi.Logger|Error|   Failed to load controller 'Home' since the plugin name is not specified.
I will be grateful for any help.
Apr 29, 2013 at 12:21 PM
Edited Apr 29, 2013 at 8:20 PM
Ok
I found the source of the problem.
Image
http://www.freeimagehosting.net/6ezpf

Exception text:
Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.
I changed the controller name in TestPlugin from Home to new name and it started to work.

Do you plan in near future distinguish controllers with the same name belonging to the different projects.??

Br
Coordinator
May 7, 2013 at 3:06 AM
Edited May 14, 2013 at 8:09 AM
Hi,
This bug is fixed in version 1.2.0.0. In the old version, I add a customized route to get plugin name, the route looks like this:
{plugin}/{controller}/{action}. I realized this is a bad idea, so I removed the customized route, and pass plugin name via query string, so the url in plugin changed to
/Contact/Index?plugin=ContactUsPlugin from /ContactUsPlugin/Contact/Index

In the html code, you can follow below sample,

@foreach (var movie in Model)
    {
        <tr>
            <td><a href="#">@movie.Name</a></td>
            <td>@movie.Rating</td>
            <td> @Html.ActionLink("Delete", "Delete", new { plugin="MediaPlugin", id=movie.Id})</td>
        </tr>
    }
In this way, Controller name can be same for all plugins.

Joey