'Unity3d reports error when accessing Redis database?
Unity3d version: 2021.3.0f1c1
VS version: VS2022
Install StackExchange.Redis using NuGetForUnity
StackExchange.Redis version: 2.5.61
Code:
private IDatabase db;
void Start()
{
Debug.Log("Prepare to connect to redis");
ConnectionMultiplexer _conn = ConnectionMultiplexer.Connect("127.0.0.1:6379,allowadmin=true,password=password01!");
var database = _conn.GetDatabase(1);
string str = database.StringGet("name");
Debug.Log(str);
}
error message:
InvalidOperationException: The assembly for System.Runtime.CompilerServices.Unsafe could not be loaded; this usually means a missing assembly binding redirect - try checking this, and adding any that are missing; note that it is not always possible to add this redirects - for example 'azure functions v1'; it looks like you may need to use 'azure functions v2' for that - sorry, but that's out of our control
Pipelines.Sockets.Unofficial.Internal.Throw.InvalidOperation (System.String message) (at /_/src/Pipelines.Sockets.Unofficial/Internal/Throw.cs:16)
Pipelines.Sockets.Unofficial.Helpers.AssertDependencies () (at /_/src/Pipelines.Sockets.Unofficial/Helpers.cs:177)
Pipelines.Sockets.Unofficial.SocketConnection.AssertDependencies () (at /_/src/Pipelines.Sockets.Unofficial/SocketConnection.cs:121)
StackExchange.Redis.ConnectionMultiplexer.Connect (StackExchange.Redis.ConfigurationOptions configuration, System.IO.TextWriter log) (at /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:673)
StackExchange.Redis.ConnectionMultiplexer.Connect (System.String configuration, System.IO.TextWriter log) (at /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:654)
NewBehaviourScript.Start () (at Assets/Scenes/NewBehaviourScript.cs:13)
Solution 1:[1]
It looks like this is a very frequent problem, so frequent if fact there was a blog post written about it. This was mentioned in a github discussion about the same exact error. That post will do a far better job at explaining than I can here.
If none of that helps you, I found another discussion involving the error at this link on github which lists many more solutions. Outside of that, you may want to provide more details as to what started this problem, ie is this only recent after an update or is this your first time trying it?
If even that fails, this question would be far better asked at the github issues for that package located here, where they can help you more in depth.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
