Description
I have netstandard2.0 project which is wrapper around StackExchange.Redis nuget. I have net8.0 console project which is using netstandard2.0 one.
I'm getting the following runtime error:
"Method not found: 'Void StackExchange.Redis.ConfigurationOptions.set_EndPoints(StackExchange.Redis.EndPointCollection)'."}
ClassName: null
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233069
HasBeenThrown: true
HelpLink: null
InnerException: null
MemberName: null
Message: "Method not found: 'Void StackExchange.Redis.ConfigurationOptions.set_EndPoints(StackExchange.Redis.EndPointCollection)'."
SerializationStackTraceString: " at CacheWrapper.CacheWrapper.BuildConfigurationOptions()\r\n at CacheWrapper.CacheWrapper..ctor() in CacheWrapper.cs:line 11\r\n at Program.<Main>$(String[] args) in Program.cs:line 3"
SerializationWatsonBuckets: null
Signature: null
Source: "CacheWrapper"
As I understand that the problem is in StackExchange.Redis nuget package which uses init only setters in netstandard version of the library.
Reproduction Steps
CacheWrapper.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
</ItemGroup>
</Project>
CacheWrapper.cs
using StackExchange.Redis;
namespace CacheWrapper
{
public class CacheWrapper
{
private readonly ConfigurationOptions _options;
public CacheWrapper()
{
_options = BuildConfigurationOptions();
}
public IDatabase Connect()
{
var connectionMultiplexer = ConnectionMultiplexer.Connect(_options);
return connectionMultiplexer.GetDatabase();
}
internal ConfigurationOptions BuildConfigurationOptions()
{
var endPoints = new EndPointCollection { { "127.0.0.1", 11111 } };
return
new ConfigurationOptions
{
AbortOnConnectFail = false,
EndPoints = endPoints,
SyncTimeout = 30000
};
}
}
}
CacheUser.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\CacheWrapper\CacheWrapper.csproj" />
</ItemGroup>
</Project>
Program.cs
var cache = new CacheWrapper.CacheWrapper();
This code works if my console application is targeting net48.
Description
I have netstandard2.0 project which is wrapper around StackExchange.Redis nuget. I have net8.0 console project which is using netstandard2.0 one.
I'm getting the following runtime error:
As I understand that the problem is in StackExchange.Redis nuget package which uses init only setters in netstandard version of the library.
Reproduction Steps
CacheWrapper.csproj
CacheWrapper.cs
CacheUser.csproj
Program.cs
This code works if my console application is targeting net48.