The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, OracleConnection]) failed: Could not load file or assembly 'System.Data.OracleClient, Version=2.0.0.0

Topics: Data Access Application Block
Aug 31, 2010 at 8:21 PM

I'm trying access a WCF service from an ASP.NET web with impersonation.   I'm receiving the following error:

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, OracleConnection]) failed: Could not load file or assembly 'System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied. (Strategy type ConfiguredObjectStrategy, index 2)

Here's part of my web.config on the service:

<connectionStrings >
      <add name="OracleConnection" connectionString="user id=abc;data source=Dev.Abc.com;password=abc123"
      providerName="System.Data.OracleClient"  />
</connectionStrings>
<dataConfiguration defaultDatabase="OracleConnection" />

What am I doing wrong?  This used to work before I tried using impersonation.

Thanks!

Sep 1, 2010 at 12:45 AM

Please post the exact code which throws the exception.  What version of entlib and .net framework are you using?  In addition, are you referencing the Microsoft.Practices.EnterpriseLibrary.Data assembly from GAC? 

 

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

Sep 1, 2010 at 2:01 PM
Edited Sep 1, 2010 at 4:00 PM

I'm using enlib 4.1 and .NET Framework 3.5.  I am not referencing .Data assembly from the GAC.  The following is the code:

ASP.NET Client

Collection<ServiceReferenceCTM.ActiveSubstance> substances;
using (((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate())
{
 ServiceReferenceCTM.CTMServiceClient proxy = new ServiceReferenceCTM.CTMServiceClient();
 substances = new Collection<ServiceReferenceCTM.ActiveSubstance>();
 substances = proxy.GetActiveSubstances();
 proxy.Close();
}


WCF Service

[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public Collection<ActiveSubstance> GetActiveSubstances()
{
 Database databaseObject = DatabaseFactory.CreateDatabase("OracleConnection");  This line throws the exception
 Collection<ActiveSubstance> activeSubstances = new Collection<ActiveSubstance>();

Exception

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, OracleConnection]) failed: Could not load file or assembly 'System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied. (Strategy type ConfiguredObjectStrategy, index 2)

Inner Exception

{"Could not load file or assembly 'System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Access is denied.":"System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"} 

 

 


Sep 2, 2010 at 6:48 AM

I believe your problem is the same with the one discussed on this thread http://entlib.codeplex.com/Thread/View.aspx?ThreadId=29040.

Trying it out myself, I was able to make it work by adding the following configuration in my client's configuration (in your case your ASP.NET App). Please try and see if it will also solve your problem.

<client>

      <endpoint address=http://myserver/wcfrepro2/Service1.svc

                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"

                behaviorConfiguration="EndpointBehavior"

                contract="IService1" name="BasicHttpBinding_IService1" />

    </client>

    <behaviors>

      <endpointBehaviors>

        <behavior name="EndpointBehavior">

          <clientCredentials>

            <windows allowedImpersonationLevel="Impersonation" />

          </clientCredentials>

        </behavior>

      </endpointBehaviors>

    </behaviors>

 

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com