2016-09-28 41 views
0

我有一個MEF系統託管的MVC 4應用程序。每次系統嘗試創建由MEF注入的控制器時,都會發生此錯誤:MEF指定的參數超出了有效值的範圍。參數名稱:網站

組合物產生單個組合錯誤。根本原因是 下面提供。查看 的CompositionException.Errors屬性更詳細的信息。

1)指定的參數超出了有效值的範圍。參數 名稱:site

產生:嘗試創建類型爲'EAccountingControllers.EAccountingController'的實例 時發生異常。

造成:無法激活部分 'EAccountingControllers.EAccountingController'。元素: EAccountingControllers.EAccountingController - > EAccountingControllers.EAccountingController - > AssemblyCatalog (大會= 「EAccounting,版本= 1.0.0.0,文化=中立, 公鑰=空」)

,導致:無法獲得出口 'EAccountingControllers.EAccountingController (ContractName =「EAccounting」)''部分 'EAccountingControllers.EAccountingController'。元素: EAccountingControllers.EAccountingController (ContractName = 「EAccounting」) - > EAccountingControllers.EAccountingController - > AssemblyCatalog (大會= 「EAccounting,版本= 1.0.0.0,文化=中立, 公鑰=空」)

這很好如果我在本地IIS上託管,但是當我託管在外部託管提供程序時會產生錯誤。

什麼是造成此錯誤?

回答

0

嘗試檢查EAccountingController的構造函數中發生了什麼。我在Windows服務/控制檯應用程序中遇到了同樣的問題,事實證明,由於我的開發環境和生產環境之間存在環境差異,我正在加載MEF部件的構造函數中有未處理的異常。

錯誤消息的關鍵部分是:

An exception occurred while trying to create an instance of type '[somenamespace.sometypename]'.

在你的情況下,EAccountingControllers.EAccountingController

這不是MEF錯誤,因爲它是未處理的異常發生試圖創建EAccountingController(即可能在構造函數中)的實例。

該問題的答案可能在於EAccountingController以及它在創建實例時的作用。

相關問題