Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Cannot use Caching 5 with Data 6.1 RC #34

@memark

Description

@memark

Trying out the new Data 6.1 RC. It works fine by itself. So does Caching 5. But combined, there is a reference conflict.

Repro:

Project.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="CommonServiceLocator.NetCore" Version="1.3.1" />
    <PackageReference Include="EnterpriseLibrary.Caching.NetCore" Version="5.0.512" />
    <PackageReference Include="EnterpriseLibrary.Data.NetCore" Version="6.1.10-rc" />
  </ItemGroup>

</Project>

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  
  <configSections>
    <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.512.0, Culture=neutral, PublicKeyToken=null" />
  </configSections>

  <cachingConfiguration defaultCacheManager="Cache Manager">
    <cacheManagers>
      <add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.512.0, Culture=neutral, PublicKeyToken=null" backingStoreName="Null Storage"
           expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" />
    </cacheManagers>
    <backingStores>
      <add name="Null Storage" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.512.0, Culture=neutral, PublicKeyToken=null" />
    </backingStores>
  </cachingConfiguration>
  
</configuration>

Program.cs

using Microsoft.Practices.EnterpriseLibrary.Caching;
using System;

namespace EntLibCachingConflict
{
    class Program
    {
        static void Main()
        {
            var cacheManager = CacheFactory.GetCacheManager();
            Console.WriteLine($"cacheManager: {cacheManager}");
        }
    }
}

Run the program. It fails with exception

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.InnerGetCacheManager(String cacheManagerName)
at EntLibCachingConflict.Program.Main()

With extended logging I got some more information (private information replace with ...)

Pre-bind state information
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///.../
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null.

LOG: This bind starts in default load context.
LOG: Using application configuration file: ....
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///.../bin/Debug/net461/Microsoft.Practices.EnterpriseLibrary.Common.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

(When downgrading to Data 6.0.1313, it works.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions