![](/img/trans.png)
[英]Specified argument was out of the range of valid values. Parameter name: site
[英]MEF Specified argument was out of the range of valid values. Parameter name: site
我有一個托管的帶有MEF系統的MVC 4應用程序。 每次系統嘗試創建由MEF注入的控制器時,都會發生此錯誤:
構圖產生單個構圖錯誤。 根本原因在下面提供。 查看CompositionException.Errors屬性以獲取更多詳細信息。
1)指定的參數超出有效值范圍。 參數名稱:site
結果是:嘗試創建類型為'EAccountingControllers.EAccountingController'的實例時發生異常。
結果:無法激活零件'EAccountingControllers.EAccountingController'。 元素:EAccountingControllers.EAccountingController-> EAccountingControllers.EAccountingController-> AssemblyCatalog(Assembly =“ EAccounting,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null”)
結果:無法從“ EAccountingControllers.EAccountingController”部分導出導出“ EAccountingControllers.EAccountingController(ContractName =“ EAccounting”)”。 元素:EAccountingControllers.EAccountingController(ContractName =“ EAccounting”)-> EAccountingControllers.EAccountingController-> AssemblyCatalog(Assembly =“ EAccounting,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null”)
如果我托管在本地IIS上很好,但是當托管在外部托管提供程序上時會產生錯誤。
是什么導致此錯誤?
嘗試檢查EAccountingController
的構造函數中發生了什么。 我在Windows服務/控制台應用程序中遇到了相同的問題,結果發現我正在加載的MEF部分的構造函數中有未處理的異常(由於開發環境和生產環境之間的環境差異)。
錯誤消息的關鍵部分是:
An exception occurred while trying to create an instance of type '[somenamespace.sometypename]'.
在您的情況下,它是EAccountingControllers.EAccountingController
。
這與其說是MEF的錯誤,因為它試圖創建的實例發生未處理的異常EAccountingController
(即可能是在構造函數)。
問題可能是什么的答案在EAccountingController
以及在創建實例時它會做什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.