简体   繁体   中英

Using Unity in child web site (IIS 8.5): “An abstract InjectionMemberElement object cannot be created.”

I am trying to create a child web site in IIS 8.5 and running into a configuration error on the line of the web.config.

The error is as follows:

Server Error in '/Holiday' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred creating the configuration section handler for unity: An abstract InjectionMemberElement object cannot be created. Please specify a concrete type.

The parent application also uses Unity for dependency injection.

Any way to avoid this? It does not appear that there is any way to tell the site to ignore the parent Unity configuration.

You should be able to put different names on the web.config sections in the parent and child website.

Parent:

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

Child:

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

This should prevent the sections from conflicting. You can also do a remove in the child config specifying the parent section name:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM