The type Database does not have an accessible constructor [ORACLE ODP]

Topics: Data Access Application Block
Nov 21, 2012 at 7:23 PM

Hello, I'm writing here because I basically gave up with this....

I'm using latest ODP.net in an asp project, while testing on my development machine the app connects, but when I deploy it to the test server I gue this:

 

 

The type Database does not have an accessible constructor. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The type Database does not have an accessible constructor.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[InvalidOperationException: The type Database does not have an accessible constructor.]
   Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForNullExistingObject(IBuilderContext context) +171
   BuildUp_Microsoft.Practices.EnterpriseLibrary.Data.Database(IBuilderContext ) +63
   Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) +12
   Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +195
   Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +190
   Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +163

[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)
]
   Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +327
   Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides) +15
   Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key) +43
   Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) +50

[ActivationException: Activation error occured while trying to get instance of type Database, key ""]
   Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) +110
   Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance() +65
   App.Logic.Data.DBOracle.Recuperar(DataSet& ds, String sTabla, String query, CommandType type) +47
   App.Data.Administracion.DSUsuario.LogIn(String IdUsuario_In, DataSet& ds) +54
   App.Logic.Negocios.BSUsuario.LogIn(LogicSessionUsuario& Usuario, String IdUsuario_In, String Contrasenia, String& pwdoriginal) +105
   LINK.UserControls.LogIn.btnAceptar_Click(Object sender, EventArgs e) +259
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

 

 

My Data Access Layers has this:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using EntLibContrib.Data.OdpNet;
using System.Configuration;
using Oracle.DataAccess.Client;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;


        public void RetrieveData(ref DataSet ds, string sTabla, string query, CommandType type)
        {
            Database db = EnterpriseLibraryContainer.Current.GetInstance();

            DbCommand dbCommand;

            if (type.Equals(CommandType.StoredProcedure))
            {
                dbCommand = db.GetStoredProcCommand(query);
            }
            else
            {
                dbCommand = db.GetSqlStringCommand(query);
            }

            // Si hay parametros, los agrego a la consulta
            AgregarParametrosCommando(db, dbCommand);
            ds = db.ExecuteDataSet(dbCommand);
        }

public void Retrieve(ref DataSet ds, string sTable, string query, CommandType type) { Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>(); DbCommand dbCommand; if (type.Equals(CommandType.StoredProcedure)) { dbCommand = db.GetStoredProcCommand(query); } else { dbCommand = db.GetSqlStringCommand(query); } // Si hay parametros, los agrego a la consulta AgregarParametrosCommando(db, dbCommand); ds = db.ExecuteDataSet(dbCommand); }

my DLL reads this app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    </configSections>
    <dataConfiguration defaultDatabase="LINK13" />
    <connectionStrings>
        <add name="LINK13" connectionString="Data Source=DMS20137F.WORLD;Password=LINK13;User Id=LINK13;"
            providerName="Oracle.DataAccess.Client" />
    </connectionStrings>
</configuration>

 

in my web config I have this:

  <system.data>
    <DbProviderFactories>
      <add name="EntLibContrib.Data.OdpNet" invariant="EntLibContrib.Data.OdpNet" description="EntLibContrib Data OdpNet Provider" type="EntLibContrib.Data.OdpNet.OracleDatabase, EntLibContrib.Data.OdpNet, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null" />
    </DbProviderFactories>
  </system.data>

 

I don't get it, why my app doesn't work on the server which is a: Windows Server 2008 R2, I already enabled on my app pool 32bits apps.

Any idea? thanks

Nov 21, 2012 at 8:04 PM

First Error solved with machine.config on server.