Enterprise library with SQL CE 4.0 database throwing InvalidOperationException for Private installation

0 votes
asked Jul 29, 2015 in SQL Server by Thiyagarajan

I am using Enterprise Library 5.0 with SQL CE 4.0 compact database. My code is working fine when I have SQL CE installed on the local machine. But in server, we do not want to install SQL CE compact DB, instead we would like to use the Private installation method. I have followed the instruction provide in the MSDN Url, but still it is not working. When I ran my code, it is throwing below exception. I searched all over the places in the internet but, I could not find a definite solution so far. Did any one come across the same issue?

Here is my app config information

<configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" requirePermission="false"/>
  </configSections>

<dataConfiguration defaultDatabase="LocalDbContext"/>
  <connectionStrings>
    <add name="LocalDbContext" connectionString="Data Source=|DataDirectory|\LocalDb.sdf" providerName="System.Data.SqlServerCe.4.0"/>
  </connectionStrings>

Exception:

Service cannot be started. System.TypeInitializationException: The type initializer for 'MyRepository' threw an exception. ---> Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type Database, key "LocalDbContext" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "EventBackPlaneLocalDbContext".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,EventBackPlaneLocalDbContext
 ---> System.InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value.
 ...
Share

Your answer

Preview

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
site design / logo / content © 2013 - 2015 pinfaq.com
...