2011-12-01 49 views
0

將解決方案從MVC 1.0.0.0 Visual Studio 2008遷移到MVC 2.0.0.0 Visual Studio 2010後,以下錯誤:將解決方案從MVC 1.0.0.0 Visual Studio 2008遷移到MVC 2.0.0.0後出現錯誤Visual Studio 2010(IControllerFactory)

The controller factory type 'MyLib.MyControllerFactory' must implement the IControllerFactory interface.

Parameter name: 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.

Exception Details: System.ArgumentException: The controller factory type 'MyLib.MyControllerFactory' must implement the IControllerFactory interface. Parameter name: controllerFactoryType

 
Source Error: 

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

MyLib中是MVC實現的外部共享庫1.0.0.0

回答

0

這裏的解決辦法,我發現,使我的下MVC 2.0網站遷移到Visual Studio 2010中

在Application_Start在Global.asax中我只是用實現類實例化的IControllerFactory工作我的MVC 1.0.0.0依賴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: Entry point was not found.] 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 callback, Object state) +85 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +392 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263

這是因爲傳統MVC 1.0庫無法解析MVC對應用程序中加載的MVC 2.0庫中接口的引用。

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

我也:

我通過在配置文件中添加以下部分來添加組件從System.Web.Mvc 1.0.0.0到System.Web.Mvc 2.0.0.0結合解決了這個必須將此配置塊添加到我的單元測試項目中的app.config文件以修復損壞的測試。

1

MyLib is an external shared library implemented in MVC 1.0.0.0

你將不得不重新編譯(如果喲你有源代碼),或者要求庫的作者爲你提供一個針對System.Web.Mvc 2.0.0.0編譯的版本,否則這將不起作用。

+0

嗨,謝謝你的幫助。我找到了一種方法使其工作,但不能發佈答案(網站限制8小時)。它需要在global.asax和運行時配置設置中將MVC 1.0.0.0映射到MVC 2.0.0.0。我明天會發布。 –

+0

圖書館的重新編譯也不是一個好的選擇,因爲它在其他團隊擁有的多個項目中共享。 –

相關問題