StackExchange.Redis crashing .NET webapi

0

I have create a new .Net core 3.1 web api, that has no other dependencies except StackExchange.Redis.

In StartUp.cs, I am setting up the connection as

public static ConnectionMultiplexer redis;
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
            redis = ConnectionMultiplexer.Connect("localhost"); ...

and then later setting up a key as

string value = "run at " + DateTime.Now.ToString();
IDatabase db = Startup.redis.GetDatabase();
db.StringSet("test_key", value, new System.TimeSpan(3, 0, 0));

This works fine in my development environment, but in the production environment it crashes. I get the following error

Faulting application name: w3wp.exe, version: 10.0.14393.0, time stamp: 0x57899135
Faulting module name: coreclr.dll, version: 4.700.20.51601, time stamp: 0x5f89f166
Exception code: 0xc0000005
Fault offset: 0x00061471
Faulting process id: 0x2f008
Faulting application start time: 0x01d73e02dc5d058e
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\3.1.10\coreclr.dll
Report Id: 1104748b-7a7e-4e07-9302-a34883fada38
Faulting package full name: 
Faulting package-relative application ID: 

Redis is working fine in production and development environment.

c#
redis
asked on Stack Overflow Apr 30, 2021 by dhiman

1 Answer

0

I compiled it as the application dotnet publish . -o ..\publishedAPI -r win-x64

then in the pool I set Enable 32-bit application = False

and it started working..

answered on Stack Overflow May 3, 2021 by dhiman

User contributions licensed under CC BY-SA 3.0