ConnectionMultiplexer.Connect在连接到Redis服务器时中断 [英] ConnectionMultiplexer.Connect breaks while connecting to redis server

查看:902
本文介绍了ConnectionMultiplexer.Connect在连接到Redis服务器时中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在Windows 7计算机上成功安装Redis服务器. 快速动手,一切都按预期进行. (使用MSI安装程序从 https://github.com/MSOpenTech/redis 安装)

I successfully installed the Redis server on my Windows 7 machine. Did a quick hands on, everything works as expected. (installed using the MSI installer from https://github.com/MSOpenTech/redis )

我正在使用StackExchange Redis客户端C#连接到Redis服务器.
RedisClient

I am using the StackExchange redis client C# for connecting to Redis server.
RedisClient

P.S. :由于我安装了VS 2010,因此未在计算机上构建应用程序,这引发了一些错误.所以我安装了nuget软件包,现在我的C#测试应用程序具有程序集 StackExchange.Redis

P.S. : I did not build the application on my machine as I am having VS 2010 and that was throwing some error. So i installed the nuget package and now my Test App in C# has the assembly StackExchange.Redis

我的控制台应用程序很简单,只需一行代码

My console app is simple with just one line of code

    ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379,allowAdmin=true");

它给我一个错误:

System.AggregateException was unhandled
  HResult=-2146233088
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
       at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout)
       at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Func`1 multiplexerFactory, TextWriter log) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 817
       at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 795
       at testapp.Program.Main(String[] args) in D:\_Work\TestApp\Program.cs:line 64
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Security.VerificationException
       HResult=-2146233075
       Message=Method System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[System.Boolean].AwaitUnsafeOnCompleted: type argument 'Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[StackExchange.Redis.ServerEndPoint]' violates the constraint of type parameter 'TAwaiter'.
       Source=StackExchange.Redis
       StackTrace:
            at StackExchange.Redis.ConnectionMultiplexer.<ReconfigureAsync>d__2d.MoveNext()
            at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
            at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
            at StackExchange.Redis.ConnectionMultiplexer.ReconfigureAsync(Boolean first, Boolean reconfigureAll, TextWriter log, EndPoint blame, String cause, Boolean publishReconfigure, CommandFlags publishReconfigureFlags)
            at StackExchange.Redis.ConnectionMultiplexer.<>c__DisplayClass29.<ConnectImpl>b__26() in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 815
            at System.Threading.Tasks.Task`1.InnerInvoke()
            at System.Threading.Tasks.Task.Execute()
       InnerException: 

推荐答案

对于其他偶然发现此问题的人,原因是与Microsoft.Bcl软件包的版本不匹配.运行命令Update-Package Microsoft.Bcl进行解析.

For anyone else who stumbles on this the cause is a version mismatch with the Microsoft.Bcl package. Run the command Update-Package Microsoft.Bcl to resolve.

请参见 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆