Reputation: 8636
I installed Redis StackExchange nuget and things worked fine. But then I installed RedisSessionStateProvider nuget, which installed StackExchange.Redis.StrongName along with it.
Now I am getting the following error,
Error 107 The type 'StackExchange.Redis.IDatabase' exists in both 'e:\Source\packages\StackExchange.Redis.1.0.481\lib\net45\StackExchange.Redis.dll' and 'e:\Source\packages\StackExchange.Redis.StrongName.1.0.481\lib\net45\StackExchange.Redis.StrongName.dll' E:\Source\MyApp\Helpers\RedisHelper\StackExchangeRedisExtensions.cs 13 37 MyApp
Why is this?
Upvotes: 4
Views: 4029
Reputation: 104811
I faced this issue in an ASP.NET Core app, and this answer solved my issue quickly.
Upvotes: 0
Reputation: 588
There's a lot of confusion between the strong-named dll and the non-strong-named dll namespaces.
You can easily solve this by using extern alias
.
Aliases
field value to anything you want. E.g: "Redis".Then go to your consumer source-file and add:
extern alias Redis;
using System;
// ... other references
using Redis::StackExchange.Redis;
namespace Foo
{
public class Program
{
public static void Main(string[] args)
{
using (ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("myConn"))
{
// use StackExchange API here.
}
}
}
}
There's also an issue on StackExchange's repository explaining more about StrongName vs Non-StrongName.
Upvotes: 10
Reputation: 965
Some methods/properties/interfaces are duplicated
in above 2 dlls.
Remove StackExchange.Redis reference to resolve errors.
Upvotes: 4