Вот обходной путь, который я нашел, чтобы заставить работать мою зависимость 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 в моем проекте модульных тестов, чтобы исправить сломанные тесты.