Invalid operation exception when deploying using Enterprise Library

Invalid operation exception when deploying using Enterprise Library

Postby NQM88 » Fri 22 Mar 2013 20:43

Hello,

I am evaluating the use of the Devart Oracle driver in conjunction with the MS Enterprise Library Data Access Block. I have a simple console application that I can run without issue on my local machine. When attempting to run the executable after deploying it to a staging server I am getting the following error. Is there something specific I need to do when deploying an application which uses the Devart driver?

2013-03-22 20:34:44.4872,Error,DAL.ResultRepository.GetResultData,Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type Database, key "" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database does not have an accessible constructor.
-----------------------------------------------
At the time of the exception, the container was:

Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)
---> System.InvalidOperationException: The type Database does not have an accessible constructor.
at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForNullExistingObject(IBuilderContext context)
at BuildUp_Microsoft.Practices.EnterpriseLibrary.Data.Database(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
--- End of inner exception stack trace ---
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 49
--- End of inner exception stack trace ---
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 53
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key) in c:\Home\Chris\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 103
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String name)
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()
at DAL.ResultRepository.GetResultData(String tenantId, String assessmentKeys, DateTime startDate, DateTime endDate, String groupKeys) in C:\TFS2\Analytics\spikes\ItemAnalysisConsoleNoOdp\DAL\ResultRepository.cs:line 67
NQM88
 
Posts: 1
Joined: Fri 22 Mar 2013 20:37

Re: Invalid operation exception when deploying using Enterprise Library

Postby Shalex » Thu 28 Mar 2013 13:31

Please compare the following *.config with yours:
Code: Select all
<configuration>
  <configSections>
    <section name="dataConfiguration" type="
            Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
            Microsoft.Practices.EnterpriseLibrary.Data"/>
  </configSections>
  <connectionStrings>
    <add name="DataAccessQuickStart" providerName="Devart.Data.Oracle" connectionString="server=orcl1120;
                            User id = scott;
                            password = tiger;"/>
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Devart.Data.Oracle"/>
      <add name="dotConnect for Oracle" invariant="Devart.Data.Oracle" description="Devart dotConnect for Oracle" type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle, Version=7.7.226.0, Culture=neutral, PublicKeyToken=09af7300eec23701"/>
    </DbProviderFactories>
  </system.data>
  <dataConfiguration defaultDatabase="DataAccessQuickStart">
    <providerMappings>
      <add databaseType="Devart.Data.Oracle.EnterpriseLibrary.OracleDatabase,
                        Devart.Data.Oracle.EnterpriseLibrary" name="Devart.Data.Oracle"/>
    </providerMappings>
  </dataConfiguration>
</configuration>

If this doesn't help, please send us a small test project so that we can reproduce the problem in our environment.

[EDIT]: We have corrected the example above: providerName must be "Devart.Data.Oracle" instead of "dotConnect for Oracle".
Shalex
Devart Team
 
Posts: 7781
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle