Migrar de .NET MVC 1 para MVC 2 RC
-
18-09-2019 - |
Pergunta
Eu migrei um projeto MVC1 para o MVC2 RC e agora o site não funciona. Recebo o erro "O ponto de entrada não foi encontrado".
Eu migrei o projeto seguindo esse link
Estou usando o Castle Windsor como Di.
Aqui está uma parte do global.asax.cs
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", "{controller}/{action}/{id}", new { controller = "Main", action = "Index", id = "" });
}
protected void Application_Start()
{
log4net.Config.XmlConfigurator.Configure();
InitializeServiceLocator();
//RouteConfigurator.RegisterRoutesTo(RouteTable.Routes);
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
Bootstrapper.BootStrap();
}
/// <summary>
/// If you need to communicate to multiple databases, you'd add a line to this method to
/// initialize the other database as well.
/// </summary>
private void InitializeNHibernateSession()
{
var cfg =
NHibernateSession.Init(
webSessionStorage,
new string[] { Server.MapPath("~/bin/Edi.Advance.EPortfolio.Data.dll") },
new AutoPersistenceModelGenerator().Generate(),
Server.MapPath("~/hibernate.cfg.xml")).AddAssembly(typeof(ISoftDeletable).Assembly).AddAssembly(
typeof(Action).Assembly);
//cfg.SetListener(ListenerType.Delete, new AdvanceDeleteEventListener(IoC.Resolve<ISecurityContextService>()));
//cfg.SetListener(ListenerType.SaveUpdate, new AdvanceSaveUpdateEventListener(IoC.Resolve<ISecurityContextService>()));
}
/// <summary>
/// Instantiate the container and add all Controllers that derive from
/// WindsorController to the container. Also associate the Controller
/// with the WindsorContainer ControllerFactory.
/// </summary>
protected virtual void InitializeServiceLocator()
{
// AddComponentsToIoC();
var container = new WindsorContainer();
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
container.RegisterControllers(typeof(MainController));
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
}
O MainController é muito simples, a ação do índice basta retornar a string "Hello World da MVC2". (Nenhuma visão para esta ação).
As coisas interessantes são se eu comentar esta linha:
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
O MainController funciona bem, mas por causa de outros controladores mais complicados não funciona dizendo que não há construtor sem parâmetros.
Portanto, ele é algo errado com o WindsorControllerFactory.
Alguma ideia? Obrigado
Solução
Uso: Icontroller de substituição protegida
Instalado de: Icontroller de substituição protegida getControllerInstance (Type ControllerType)
Outras dicas
Usar:
Icontroller de substituição protegida GetControllerInstance (System.Web.Routing.RequestContext RequestContext, Type ControllerType)
Instalado de:
Icontroller de substituição protegida GetControllerInstance (Type ControllerType)