DAAB Question

Mar 20, 2007 at 7:02 PM
Edited Mar 20, 2007 at 7:03 PM
I just began using EL ( February 2007 CTP ) today and am having trouble with DAAB. When I call

Database db = DatabaseFactory.CreateDatabase();

An unhandled runtime exception occurs:



at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.get_DefaultName()
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseMapper.MapName(String name, IConfigurationSource configSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUpTTypeToBuild(IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUpT(IReadWriteLocator locator, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUpT(IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault()
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()
at xxxxxxxx.Data.GetJobList(xxxxxxxx) in C:\Documents and Settings\xxxxx\My Documents\Visual Studio 2005\Projects\xxxxxxxxxxx\xxxxxxxxxx\Data.cs:line 25
at DataTest.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\xxxxxxxx\My Documents\Visual Studio 2005\Projects\xxxxxxxxxx\DataTest\Form1.cs:line 26


The code breaks on the following line in DatabaseConfigurationView.cs:

public string DefaultName
{
get
{
DatabaseSettings settings = this.DatabaseSettings;
string databaseName = settings.DefaultDatabase; //HERE
return databaseName;
}
}

I think it must be something in my app. config file. If needed I can post relevant snippets from my config. Can anyone help?
Mar 20, 2007 at 7:48 PM
Ok, solved. My problem was that I needed to add references and config file settings in my windows app, not in the Data project. I was also referencing the non-strong named assembly and so I changed the config so PublicKeyToken=null as Tom suggested here:

http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=7988