2015-04-08 30 views
0

我是Azure Redis缓存的新手。我刚刚在Azure Portal中配置了Redis缓存。我已经通过nuget在我的项目中安装了StackExchange.Redis。下面是连接Redis的无法在MVC应用程序中配置Redis缓存

ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("server.redis.cache.windows.net,ssl=true,password=primary access key"); 

     IDatabase cache = connection.GetDatabase(); 

我得到以下错误,而连接代码:

JIT编译器遇到一个内部限制。

在StackExchange.Redis.ConfigurationOptions.OptionKeys.TryNormalize(字符串值) 在StackExchange.Redis.ConfigurationOptions.DoParse(字符串配置,布尔ignoreUnknown)在C:\ TeamCity的\ buildAgent \工作\ 3ae0647004edff78 \ StackExchange。 Redis \ StackExchange \ Redis \ ConfigurationOptions.cs:行501 在StackExchange.Redis.ConfigurationOptions.Parse(字符串配置)在c:\ TeamCity \ buildAgent \ work \ 3ae0647004edff78 \ StackExchange.Redis \ StackExchange \ Redis \ ConfigurationOptions.cs:行279 at c:\ TeamCity \ buildAgent \ work \ 3ae0647004edff78 \ StackExchange.Redis \ StackExchange \ Redis \ ConnectionMultiplexer.cs中的StackExchange.Redis.ConnectionMultiplexer.CreateMultiplexer(Object configuration):line 728 在StackExchange.Redis.ConnectionMultiplexer。 <> c__DisplayClass24.b__23(c)中:\ TeamCity的\ buildAgent \工作\ 3ae0647004edff78 \ StackExchange.Redis \ StackExchange \ Redis的\ ConnectionMultiplexer.cs:线745 在StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Func键1 multiplexerFactory, TextWriter log) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 761 at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 745 at App.Web.Controllers.HomeController.Index() in g:\Users\Workspaces\AlphaProject\App.Web\Controllers\HomeController.cs:line 42 at lambda_method(Closure , ControllerBase , Object[]) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary 2参数) 在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,actionDescriptor actionDescriptor,IDictionary的2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult 2.CallEndDelegate(IAsyncResult的asyncResult) 在System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() 在System.Web程序。 Mvc.Async.AsyncResultWrapper.End [TResult](IAsyncResult asyncResult,Object tag) at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncController ActionInvoker.AsyncInvocationWithFilters.b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters。 <> c__DisplayClass46.b__3f()

请建议我一些解决方案来连接Redis服务器。

在此先感谢。

回答

0

我不知道这是否有帮助。我是长打一个类似的错误说

“ArgumentNullException:值不能为空参数名: 配置 StackExchange.Redis.ConnectionMultiplexer.CreateMultiplexer(对象 配置)在ConnectionMultiplexer.cs,行844”

我看了看我的Startup.cs,并重新写了下面这行就是这样,而现在它的工作原理:

services.AddDistributedRedisCache(option => 
      { 
       option.Configuration = "pretzelcache.redis.cache.windows.net:6380,password=qD+cdEMf5SI+2Psi7zUXdGSwjKCZnhwLvb3tmi3i6O8=,ssl=True,abortConnect=False"; 
      }); 

早些时候,选项。配置直接尝试从appsettings.json文件读取connectionString,并且没有正确连接到那里。

干杯。

相关问题