0

I keep getting

System.IO.FileNotFoundException: 'Could not load file or assembly 'Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342 or one of its dependencies

error when I try to check for existence of a role. The problem is that have references to unmanaged data access"Oracle.DataAccess.dll" and none to managed!

I checked web.config and all the references and can't see where this managed data access reference is coming from. Any ideas?

using System;
using System.Web;
using System.Web.Security;
using System.Web.Routing;

public class Global : HttpApplication
{
    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        if (Roles.Enabled)
        {
            if (!Roles.RoleExists("User"))  <--- Error pops up here
            {
                Roles.CreateRole("User");
            }
            ...
        }
    }
}

In web.config:

<compilation defaultLanguage="c#" debug="true" targetFramework="4.6">
  <assemblies>
    <add assembly="Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89B483F429C47342"/>
    <add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  </assemblies>
</compilation>
....
<roleManager enabled="true" defaultProvider="AHSOracleRoleProvider">
  <providers>
    <add name="AHSOracleRoleProvider" type="Oracle.Web.Security.OracleRoleProvider, Oracle.Web, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="AHSConnectionString" applicationName="/"/>
  </providers>
</roleManager>
Ryan Wilson
  • 10,223
  • 2
  • 21
  • 40
NoBullMan
  • 2,032
  • 5
  • 40
  • 93
  • It is possible that the unmanaged reference needs the dll in the error message to function. – Ryan Wilson Aug 05 '19 at 18:41
  • 1
    Are you using the [Oracle.Web](https://www.nuget.org/packages/Oracle.Web/) NuGet package? It depends on the *managed* provider. – madreflection Aug 05 '19 at 18:45
  • No, I have instaled Oracle 12C client on my machine and used the files in oracle installation folder to reference (from ODP.Net and ASP.NET folders) – NoBullMan Aug 05 '19 at 18:51
  • @NoBullMan Have you opened the project file in a text editor and looked at the references inside of it? – Ryan Wilson Aug 05 '19 at 18:55
  • I opened AHS.csproj and AHS.csproj.user in notepad and looked for "managed"; not there. – NoBullMan Aug 05 '19 at 18:59
  • @NoBullMan Have you always had this error, or is it something that has just started happening? – Ryan Wilson Aug 05 '19 at 19:01
  • @NoBullMan Have you given this SO post a read? (https://stackoverflow.com/questions/1953676/could-not-load-file-or-assembly-for-oracle-dataaccess-in-net) – Ryan Wilson Aug 05 '19 at 19:04
  • It just started, it was fine up until a couple of hours ago. The only thing I did was publish and copy to test server (from my local machine). I temporarily changed platform target in Project properties from "Any CPU" to "x64" and changed back (I am using 64-bit versions of Oracle DLLs). after publishing, everything went haywire! – NoBullMan Aug 05 '19 at 19:05
  • @NoBullMan Sometimes the `.suo` file can be problematic. See if deleting that along with everything in `bin` and `obj` and rebuilding as `ANY CPU` fixes it. Also, check to make sure you are running in `debug` and not `release`, also see if you have the `Oracle .dll` set to copy local true. – Ryan Wilson Aug 05 '19 at 19:07
  • I will try and post the result. – NoBullMan Aug 05 '19 at 19:08
  • did you mean ".suo" or ".sln"? I can't see ".slo" – NoBullMan Aug 05 '19 at 19:09
  • @NoBullMan I meant `.suo`, sorry, typo – Ryan Wilson Aug 05 '19 at 19:10
  • 1
    You said you're not using the Oracle.Web package. But your AHSOracleProvider does, which has an [explicit dependency](https://www.fuget.org/packages/Oracle.Web) on Oracle.ManagedDataAccess, as madreflection pointed out above. So you need to make sure it gets deployed properly. This is a good thing by the way - the managed driver is far easier to work with than the unmanaged libraries that also have a dependency on external tools being installed. – mason Aug 05 '19 at 19:26
  • Bu this is not a NuGet package; I installed Oracle 12c client on both my local machine and app server and it is from this installation folders that the references to oracle data access and oracle web are made. – NoBullMan Aug 06 '19 at 11:47
  • I ended up adding a reference to Oracle.ManagedDataAccess DLL from oracle client installation folder to fix the issue. – NoBullMan Aug 06 '19 at 17:10

0 Answers0