2014-10-06 51 views
0

我正在嘗試在IIS 8.5中創建一個子網站,並運行到web.config行的配置錯誤中。在子網站(IIS 8.5)中使用Unity:「無法創建抽象的InjectionMemberElement對象。」

的錯誤是如下: '/假日' 應用

服務器錯誤。

配置錯誤

說明:該請求提供服務所需的配置文件的處理過程中發生了錯誤。請查看下面的具體錯誤細節並適當修改您的配置文件。

解析器錯誤消息:爲unity創建配置節處理程序時發生錯誤:無法創建抽象的InjectionMemberElement對象。請指定具體類型。

父應用程序還使用Unity進行依賴注入。

有什麼辦法可以避免這種情況?似乎沒有任何辦法可以告訴站點忽略父Unity配置。

回答

1

您應該可以在父級和子級網站的web.config部分放置不同的名稱。

家長:

<configSections> 
    <section name="unityParent" type=" ... "/> 
    </configSections> 
    <unityParent xmlns="..."></unityParent> 

兒童:

<configSections> 
    <section name="unityChild" type=" ... "/> 
    </configSections> 
    <unityChild xmlns="..."></unityChild> 

這可以防止部分從衝突的。您也可以在指定父節名稱的子配置中執行刪除操作:

<configSections> 
    <remove name="unityParent"/> 
    <section name="unityChild" type=" ... "/> 
</configSections> 
<unityChild xmlns="..."></unityChild> 
+0

您知道如何去除由孩子繼承的unityParent嗎? – 2014-10-06 06:17:07

+0

我更新了答案 – pln 2014-10-06 06:31:36

+0

如果您的代碼使用'Container.LoadConfiguration()',則需要將其更改爲'Container.LoadConfiguration((UnityConfigurationSection)ConfigurationManager.GetSection(「unityChild」))''。 – 2018-03-06 18:12:40