Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackExchange.Redis.StrongName is refrenced but not included as package

I'm starting a new project using StackExchange.Redis and .Net Core 2.0. But I get a conflict:

The type 'ConnectionMultiplexer' exists in both 'StackExchange.Redis.StrongName, Version=1.2.4.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46' and 'StackExchange.Redis, Version=1.2.6.0, Culture=neutral, PublicKeyToken=null'

Why is this showing even thou I'm not referencing StackExchange.Redis.StrongName and it's not even the same assembly version?

like image 714
Lejdholt Avatar asked Sep 05 '17 05:09

Lejdholt


3 Answers

I found my solution here.

By adding this (below) to my csproj:

<Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
  <ItemGroup>
    <ReferencePath Condition="'%(FileName)' == 'StackExchange.Redis.StrongName'">
      <Aliases>signed</Aliases>
    </ReferencePath>
  </ItemGroup>
</Target>
like image 177
Alvin Lim Avatar answered Nov 11 '22 03:11

Alvin Lim


It is possible to use Strongname in your entire application, 1.2.6 is newer and will be used. The problem is when you add Redis.Stackexchange you will have the same namespace from two different dll's. .Net compiler doesn't know which one to use. If you need 1.2.6, use the StrongName version throughout your application and no more problems ....

like image 29
André Avatar answered Nov 11 '22 02:11

André


I added a conditional flag to the "StackExchange.Redis" package, that makes it work. I Tried this solution on two new projects on two machines. Don't ask me why it works tho.

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
      </PropertyGroup>

      <ItemGroup>
        <Folder Include="wwwroot\" />
      </ItemGroup>

      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
      </ItemGroup> 
      <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
        <PackageReference Include="StackExchange.Redis" Version="1.2.6" />
      </ItemGroup>

    </Project>
like image 4
Lejdholt Avatar answered Nov 11 '22 02:11

Lejdholt