Current build operation failed exception using DAAB on vista

Topics: Data Access Application Block
Jun 2, 2009 at 5:14 PM

Hello all,

I have searched all over and cannot find a solution to this.  I have a database application that is using the Microsoft Enterprise Library 4.1 DAAB modules.  On my XP development machine I can run my code perfectly with no exceptions.  However, when I copy my executables and the enterprise library DLLs to vista I get an exception.  The exception occurs when I run the code: _database = DatabaseFactory.CreateDatabase("DBCompareConnection");

The exception is:


Exception occured: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, DBCompareConnection]) failed: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Data.Database' threw an exception. (Strategy type ConfiguredObjectStrategy, index 2)

   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)

   at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)

   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, IConfigurationSource configurationSource)

   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IConfigurationSource configurationSource)

   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault()

   at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()

   at QADatabase.BasicDatabase.Connect(DatabaseType dbType, String server, String database, String username, String password, ErrorHandlerDelegate errorHandler) in C:\projects\QALibs\QALibs\Database\QADatabase.cs:line 89

   at DBDataCompare.DataComparison.ExecuteQueries(BackgroundWorker bckWorker) in C:\projects\DB Data Compare\DBDataCompare\DataComparison.cs:line 380

   at DBDataCompare.DataComparison.ExecuteComparison(BackgroundWorker bckWorker) in C:\projects\DB Data Compare\DBDataCompare\DataComparison.cs:line 93

   at DBDataCompare.Form1.bckWorker_DoWork(Object sender, DoWorkEventArgs e) in C:\projects\DB Data Compare\DBDataCompare\Controls\Form1.cs:line 299


I cannot figure out what is causing this message.  In the released folder I have included the executable, the app.config file, the Microsoft.Practices.EnterpriseLibrary.Data.dll, Microsoft.Practices.EnterpriseLibrary.Common.dll, and the Microsoft.Practices.ObjectBuilder2.dll (all of which are correctly referenced in the c# project).  The app.config file contains:


<?xml version="1.0" encoding="utf-8" ?>




    <section name="dataConfiguration"

      type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />




    <add name="DBCompareConnection" connectionString="<valid connection string>"

      providerName="System.Data.SqlClient" />



  <dataConfiguration defaultDatabase="DBCompareConnection" />


    <trust level="Full" />

    <webControls clientScriptsLocation="/aspnet_client/{0}/{1}/" />




Can anyone give me any clue on why this exception is occurring?

Jun 3, 2009 at 2:50 AM

Are you running your visual studio using elevated permissions?  You should right click on Visual Studio and select Run As Administrator.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

Jun 3, 2009 at 3:49 PM

I'm not using Visual Studio on the Vista machine (not a dev environment).  Furthermore, the application works fine wheither I'm in Visual Studio or not on the XP machine.

Jun 4, 2009 at 6:26 AM

Can you please add the Microsoft.Practices.Unity.dll together with the executable. Looking at the source code, it seems that the Microsoft.Practices.EnterpriseLibrary.Data.dll is referencing that assembly.

Valiant Dudan
Global Technology & Solutions
Avanade, Inc.

Jun 5, 2009 at 3:24 PM

This still occurs even when including the Microsoft.Practices.Unity.Dll with the executable (as well as including the reference in the C# project) 

Jun 8, 2009 at 4:26 AM


You mentioned that the Vista Machine and that is not a dev environment. Do you have a .NET framework installed?

Valiant Dudan
Global Technology & Solutions
Avanade, Inc.

Jun 8, 2009 at 3:15 PM

Sorry for my retardedness,

I had assumed that all .net stuff was installed correctly since my c# application was previously running with no issues.  I installed the 3.5 Framework and SP1 and it all seems to be working now.

Thanks for the replies!