How can I force .NET to use a local copy of an assembly that's in the GAC

前端 未结 6 731
情话喂你
情话喂你 2020-11-29 19:42

I have a .NET assembly that (for reasons outside my control) must be in the GAC. However, the same assembly is used by another program, which has a its own copy of

6条回答
  •  悲哀的现实
    2020-11-29 20:19

    One reason the binding redirect doesn't work is because the Oracle.ManagedDataAccess provider has a different search order for dlls than the unmanaged provider. The unmanaged provider starts in the application directory, then looks in the dllpath in the registry, then the dll path in machine.config, then dll path in web.config. According to the Oracle documentation, the search order for managed provider works like this:

    Managed Driver will reference these assemblies by using the following search order:

    1. Global Assembly Cache
    2. The web application's bin directory or Windows application's EXE directory
    3. The x86 or x64 subdirectory based on whether the application runs in 32-bit or 64-bit .NET Framework. If the application is built using AnyCPU, then ODP.NET will use the correct DLL bitness as long as the assembly is available. Oracle recommends using this method of finding dependent assemblies if your application is AnyCPU.

    https://docs.oracle.com/en/database/oracle/oracle-database/12.2/odpnt/installODPmd.html#GUID-0E834EC7-21DF-4913-B712-2B0A07FD58FD

    So the way to resolve this problem is to unregister the GAC assembly OR simply put a different version of Oracle.ManagedDataAccess in your bin and web.config than what's in GAC, if you can't uninstall it.

提交回复
热议问题