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!!!

No comments: