Ошибка после миграции решения из MVC 1.0.0.0 Visual Studio 2008 в MVC 2.0.0.0 Visual Studio 2010 (IControllerFactory) - PullRequest
0 голосов
/ 01 декабря 2011

После миграции решения из MVC 1.0.0.0 Visual Studio 2008 в MVC 2.0.0.0 Visual Studio 2010 я получаю следующую ошибку:

<b>The controller factory type 'MyLib.MyControllerFactory' must implement the IControllerFactory interface.</b></p> <p> <b>Parameter name:</b> controllerFactoryType 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. </p> <p><b>Exception Details:</b> System.ArgumentException: The controller factory type 'MyLib.MyControllerFactory' must implement the IControllerFactory interface. Parameter name: controllerFactoryType

<b>Source Error: </b>

Line 35:        protected void Application_Start()
Line 36:        {
...   container initialization ...
Line 38:                 ControllerBuilder.Current.SetControllerFactory(typeof(MyControllerFactory));

MyLib - это внешняя разделяемая библиотека, реализованная в MVC 1.0.0.0

Ответы [ 2 ]

1 голос
/ 01 декабря 2011

MyLib - это внешняя общая библиотека, реализованная в MVC 1.0.0.0

Вам придется перекомпилировать (если у вас есть исходный код) или попросить автора библиотеки предоставить вамверсия, скомпилированная для System.Web.Mvc версии 2.0.0.0, или она не будет работать.

0 голосов
/ 02 декабря 2011

Вот обходной путь, который я нашел, чтобы заставить работать мою зависимость MVC 1.0.0.0 под моим сайтом MVC 2.0, перенесенную в Visual Studio 2010.

В Application_start в Global.asax я просто создал экземпляр IControllerFactory, используя класс реализации MyControllerFactory вместо попытки получить его тип:

ControllerBuilder.Current.SetControllerFactory((IControllerFactory) new MyControllerFactory());

После исправления этой ошибки я получил еще один сбой:

<b>Entry point was not found. </b>
<b>Description:</b> 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. 

<b>Exception Details:</b> System.EntryPointNotFoundException: Entry point was not found.

<b>Source Error: </b>
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

<b>Stack Trace: </b>
[EntryPointNotFoundException: точка входа не найдена.] System.Web.Mvc.IControllerFactory.CreateController (RequestContext requestContext, String controllerName) +0 System.Web.Mvc.MvcHandler.ProcessRequestInit (HttpContextBase httpContext, IController & controller, IControllerFactory & factory) +181 System.Web.Mvc.MvcHandler.BeginProcessRequest (HttpContextBase httpContext, обратный вызов AsyncCallback, состояние объекта) +85 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute () +392 System.Web.HttpApplication.ExecuteStep (шаг IExecutionStep, логический и завершен синхронно) +263

Это произошло потому, что устаревшая библиотека MVC 1.0 не смогла разрешить MVC ссылку на интерфейс в библиотеке MVC 2.0, загруженной в приложение.

Я решил эту проблему, добавив следующий раздел в файл конфигурации, чтобы добавить привязку сборки из System.Web.Mvc 1.0.0.0 в System.Web.Mvc 2.0.0.0:

.

<runtime><br> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><br> <dependentAssembly><br> <!-- Binding to help Common library MVC 1 code find the classes in MVC 2 --><br> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/><br> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/><br> </dependentAssembly><br> </assemblyBinding><br> </runtime>

Мне также пришлось добавить этот блок конфигурации в файл app.config в моем проекте модульных тестов, чтобы исправить сломанные тесты.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...