Adding EnterpriseLibraryCoreExtension to Config file

Feb 16, 2011 at 5:24 AM

Hi All,

I am creating the Unity container instance and configuring it by calling the LoadConfiguartion() methods, which inturn reads the web.config file.

ICustomerBLComponent blObj;

using (IUnityContainer container = new UnityContainer ())
{
   container.LoadConfiguration("application");
   container.AddNewExtension<ExceptionHandlingBlockExtension>();  ----- Want this entry to be moved to Web.config file

   blObj = container.Resolve<ICustomerBLComponent>("CustomerBL");
}

 <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <alias alias="ICustomerBLComponent" type="BL.ICustomerBLComponent, BL" />
    <alias alias="CustomerBL" type="BL.CustomerBL, BL" />
    <container  name="application" >
      <register type="ICustomerBLComponent" mapTo="CustomerBL" name="CustomerBL">
      </register>
      <!--<extension type="EnterpriseLibraryCoreExtension" />-->    
    </container>
  </unity>

Adding the extension as above doesn't work. Please guide me if  I have missed out any piece of code in config file.

Regards,

nprasad_guru

  

 

 

Feb 16, 2011 at 5:41 AM
Edited Feb 16, 2011 at 5:43 AM

You should define an alias for the EnterpriseLibraryCoreExtension,

<alias alias="EnterpriseLibraryCoreExtension" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity.EnterpriseLibraryCoreExtension, Microsoft.Practices.EnterpriseLibrary.Common"/>

otherwise, specify its full type name in the type attribute of the extension element.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Feb 16, 2011 at 5:49 AM

Can you please support with some code sample, as to how to define a alias for this. Also reference to any documentation on  adding Extension to Unity container will be of great help to me.

Thanks for the support.

Regards,

nprasad_guru

Feb 16, 2011 at 5:55 AM

I posted how the alias should look.  If you add it to your config, and uncomment the <extension type="EnterpriseLibraryCoreExtension" /> it should now work.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com