Thursday, October 25, 2012

InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.

I spent two hours resolving this issue today.  I was trying to resurect some tests from an old test project that I hadn't created.

The failing line of code was:
 static Database profilesDB = DatabaseFactory.CreateDatabase("profiles");

This project was using the Microsoft Enterprise Data Block version 5.0. I'm posting this solution because it was the only one that worked, after trying a dozen other things. Add the following to your App.config file:

<runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     <qualifyAssembly partialName="Microsoft.Practices.EnterpriseLibrary.Data" fullName="Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   </assemblyBinding>
</runtime>

Joy!

4 comments: