Wednesday, January 07, 2009

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type ConfiguredObjectStrategy, index 2)

         You may find this error while working with Data Application block in enterprise library. When you look into the inner exception you will find the message "The value can not be null or an empty string.".  This message does not give proper information to user.

         When enterprise library does not find default database than it will show this error. You need to add "defaultDatabase" in web.config file to solve this error.

   1: <configuration>
   2:     <configSections>          
   3:     </configSections>  
   4:     <connectionStrings>
   5:         <add connectionString="" providerName="System.Data.SqlClient"  name="ConnectionStr"/>    
   6:     </connectionStrings>
   7:   <dataConfiguration defaultDatabase="ConnectionStr" />

Fig - (1) Add DataConfiguration section to web.config file to avoid error


         When you add <dataConfiguration defaultDatabase="ConnectionStr" /> tag to web.config file you may get "Unrecognized configuration section dataConfiguration" error. Add "dataConfiguration" section in Configuration section to solve "Unrecognized configuration section dataConfiguration" error.



   1: <section name="dataConfiguration" 
   2: type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

Fig - (2) Solution of Unrecognized configuration section dataConfiguration error


 


Happy Programming!!!

Monday, January 05, 2009

An error occurred creating the configuration section, 'Microsoft.Practices.EnterpriseLibrary,The located assembly's manifest definition does not match the assembly reference

     Today I was exploring Enterprise Library 4.1 and encounter this error. I created a sample application and added reference to few DLL from "EntLib41Src\bin" folder to my application. When I hit F5 to run the application I got following error,

"An error occurred creating the configuration section handler for exceptionHandling: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

      While searching for the reason I found a link here. According to this link assemblies in "EntLib41Src\bin" folders are not strong name assemblies. So when you run the application you will encounter error as shown above. While "Program Files\Microsoft Enterprise Library 4.1 - October 2008\Bin" folder contains strong name assemblies. You have to add reference from "Program Files\Microsoft Enterprise Library 4.1 - October 2008\Bin" folder in your application.

Happy Programming !!!