views:

18

answers:

1

Hi, I keep getting this error:

Microsoft.Practices.Composite.Modularity.ModuleInitializeException was unhandled
  Message=An exception occurred while initializing module 'DiagrammerModule'. 
    - The exception message was: An exception has occurred while trying to add a view to region 'MainRegion'. 
    - The most likely causing exception was was: 'System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
   at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
   at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
   at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
....

The connection string is stored in app.config and looks like this:

<connectionStrings>
    <add name="DBEntities" connectionString="metadata=res://DataAccessLayer/EntityDataModel.csdl|res://*/EntityDataModel.ssdl|res://*/EntityDataModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=|DataDirectory|\DB.sdf;Password=password;Persist Security Info=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

where DataAccessLayer is the name of the DLL that holds the model and the entities.

What is wrong with that code?

Thanks for help.

A: 

Looks like data context constructor can't find connection string in configuration file. Check file is copied to application output directory, and have name {your-WPF-applicaiton-name}.exe.config (not {your-DLL-contains-data-context}.dll.config).

STO
I should probably add that this is Prism application. I was following this solution (scroll to the bottom of a page) where it says to insert the name of a dll: http://geekswithblogs.net/hoarked/archive/2009/02/04/creating-a-wpf-application-with-prism-v2-ndash-browse-module.aspx
Enzomatric