Unity Error: An abstract InjectionMemberElement object cannot be created

Jul 1, 2011 at 2:16 AM
Edited Jul 1, 2011 at 4:56 AM

Hi all,

I have recently inherited an ASP.Net project where Unity is used and I have never used Unity before. When I try to load a page on the project in IE 8 I receive the following error:

  An error occurred creating the configuration section handler for unity: An abstract InjectionMemberElement object cannot be created. Please specify a concrete type.  The entry in the web.config file is:

<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">

<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />

<assembly name="CNS.CRM.Web" />

   <assembly name="CNS.CRM.Business" />

   <assembly name="CNS.CRM.Data" />

   <container>

     <register type="CNS.CRM.Business.Relationship.IRelationship" mapTo="CNS.CRM.Business.Relationship.Relationship">

       <interceptor type="TransparentCRMoxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Web.IUtils" mapTo="CNS.CRM.Web.Utils">


       <!--

       Single instance of this is required, as this is a utility class.

       Also we need to cache the stuff from this, hence the interceptor.


       -->

       <lifetime type="singleton" />

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Web.UI.WebControls.WebParts.IWebPartUtil" mapTo="CNS.CRM.Web.UI.WebControls.WebParts.WebPartUtil">


       <!--

       Single instance of this is required, as this is a utility class.

       Also we need to cache the stuff from this, hence the interceptor.


       -->

       <lifetime type="singleton" />

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Business.ContactHistory.IContactHistory" mapTo="CNS.CRM.Business.ContactHistory.ContactHistory" />

     <register type="CNS.CRM.Business.Client.IClient" mapTo="CNS.CRM.Business.Client.Client" />

     <register type="CNS.CRM.Data.IDataAccess" mapTo="CNS.CRM.Data.DataAccess">

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Business.IBusinessBase" mapTo="CNS.CRM.Business.BusinessBase" />

     <register type="CNS.CRM.Business.WebParts.IWebPart" mapTo="CNS.CRM.Business.WebParts.WebPart">

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Business.Offers.IOffers" mapTo="CNS.CRM.Business.Offers.Offers" />

     <register type="CNS.CRM.Business.Application.IApplication" mapTo="CNS.CRM.Business.Application.Application">

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Business.Classification.IClassification" mapTo="CNS.CRM.Business.Classification.Classification">

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Business.Switchboard.ISwitchboard" mapTo="CNS.CRM.Business.Switchboard.Switchboard">

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

     <register type="CNS.CRM.Business.OTP.IOTP" mapTo="CNS.CRM.Business.OTP.OTP">

       <interceptor type="TransparentProxyInterceptor" />

       <policyInjection />

     </register>

   </container>

</unity>

And the stack Trace in the Event Log is:

Timestamp: 1/07/2011 12:35:30 AM

Message: HandlingInstanceID: 30158c6b-1cee-437a-b268-4d912691b3e3
An exception of type 'System.TypeInitializationException' occurred and was caught.
----------------------------------------------------------------------------------
07/01/2011 10:35:30
Type : System.TypeInitializationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The type initializer for 'Unity' threw an exception.
Source : CNS.CNS.Web
Help link :
TypeName : Unity
Data : System.Collections.ListDictionaryInternal
TargetSite : T Resolve[T]()
Stack Trace :    at CNS.CRM.Web.Application.Unity.Resolve[T]()
   at CNS.CRM.Web.Utils..cctor()

Additional Info:

MachineName : Local
TimeStamp : 1/07/2011 12:35:30 AM
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
AppDomainName : /LM/W3SVC/1/ROOT/PAR1.5.0-1-129539472094603340
ThreadIdentity : Authenticated
WindowsIdentity : IIS APPPOOL\DefaultAppPool
 Inner Exception
 ---------------
 Type : System.Configuration.ConfigurationErrorsException, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 Message : An error occurred creating the configuration section handler for unity: An abstract InjectionMemberElement object cannot be created. Please specify a concrete type. (C:\inetpub\wwwroot\CRM1.5.0\web.config line 450)
 Source : System.Configuration
 Help link :
 BareMessage : An error occurred creating the configuration section handler for unity: An abstract InjectionMemberElement object cannot be created. Please specify a concrete type.
 Filename : C:\inetpub\wwwroot\CRM1.5.0\web.config
 Line : 450
 Errors : System.Configuration.ConfigurationException[]
 Data : System.Collections.ListDictionaryInternal
 TargetSite : System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object)
 Stack Trace :    at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
    at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
    at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
    at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
    at Microsoft.Practices.Unity.Configuration.UnityContainerExtensions.LoadConfiguration(IUnityContainer container)

  Inner Exception
  ---------------
  Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  Message : An abstract InjectionMemberElement object cannot be created. Please specify a concrete type.
  Source : Microsoft.Practices.Unity.Configuration
  Help link :
  Data : System.Collections.ListDictionaryInternal
  TargetSite : System.Configuration.ConfigurationElement CreateNewElement()
  Stack Trace :    at Microsoft.Practices.Unity.Configuration.InjectionMemberElementCollection.CreateNewElement()
     at System.Configuration.ConfigurationElementCollection.CallCreateNewElement(String elementName)
     at System.Configuration.ConfigurationElementCollection.Reset(ConfigurationElement parentElement)
     at System.Configuration.ConfigurationElement.Reset(ConfigurationElement parentElement)
     at System.Configuration.ConfigurationElementCollection.Reset(ConfigurationElement parentElement)
     at System.Configuration.ConfigurationElement.Reset(ConfigurationElement parentElement)
     at System.Configuration.ConfigurationElementCollection.Reset(ConfigurationElement parentElement)
     at System.Configuration.ConfigurationElement.Reset(ConfigurationElement parentElement)
     at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
     at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
     at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
     at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)

I am running on Windows 7 64 bit with SP1

Any help/ advice here would be greatly appreciated.

Regards

Chris

 

Jul 4, 2011 at 7:33 AM
Edited Jul 4, 2011 at 7:34 AM

Hi,

Unfortunately, we can't seem to reproduce your issue. Are you running on the release mode? Maybe it would be better if you can send us a sample repro project for us to further investigate it.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 10, 2012 at 5:52 AM
Edited Jun 10, 2012 at 5:53 AM

I was facing the same issue and after hours of debugging lead me to classic case of ignorance. This was because I had web.config at root folder clashing with sub directory web.config. As soon as i resolved it by avoiding unity element from root web.config application started working without any issue.

Jun 27, 2012 at 1:49 PM
Edited Jun 27, 2012 at 1:52 PM

I managed to reproduce this issue when I use nesting of applications in IIS.

viratsarswat, could you post an example of your config file?

Jul 10, 2013 at 7:59 AM
viratsarswat wrote:
I was facing the same issue and after hours of debugging lead me to classic case of ignorance. This was because I had web.config at root folder clashing with sub directory web.config. As soon as i resolved it by avoiding unity element from root web.config application started working without any issue.
Thanks virat saraswat. You are day saver. :)
Nov 27, 2014 at 3:26 PM
Thanks virat. You saved me.