WPF + DAAB

Topics: Data Access Application Block, General discussion
May 29, 2009 at 8:01 PM

In a window, I have a window resource pointing to a method for an ObjectData Provider.

<Window.Resources>
        <ObjectDataProvider x:Key="CategoryData" ObjectType="DB:ExternalReportCategoryDB" MethodName="SelectAll" />
    </Window.Resources>

The Namespace resolves fine, but when WPF tries to bind to the Method Name, I am receiving a "The requested database cnMain is not defined in configuration. " error. When I call the method from code behind, everything works fine, no errors about missing database.

Is this a WPF issue or DAAB issue?

Below is my app.config for a WPF Windows App.

 

<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <dataConfiguration defaultDatabase="cnMain" />
  <connectionStrings>
    <add name="cnMain" connectionString="Database=xxx;Server=xxx;User Id=xx; Password=zzzz;"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

 

Thanks,

Morgan

Jun 1, 2009 at 7:53 AM

I don't know of any issue with DAAB and WPF and I tried to google if anyone ever had issue about it before and I also found none.   The code which tests the SelectAll method, is it on the same project where your ObjectDataProvider is?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 1, 2009 at 3:58 PM

Actually, no, the DB class is in another project.

Solution layout looks like this:

Solution

 -WPF Project

 -DB Project

 -BizObj Project

 

Thanks,

Morgan

Jun 2, 2009 at 8:01 AM
Edited Jun 2, 2009 at 8:03 AM

Hi,

I'm trying to do a repro of your scenario but haven't get it working. Can you please verify that the app.config is copied to your bin folder of your project? I'm not also sure if this is with DAAB or with WPF. Another thing, when you recieved the "The requested database cnMain is not defined in configuration." is it a validation error or a runtime exception.  Anyways, can you also send us your project or any quick repro for this?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com